1

好的,我一直在寻找一种简单的方法来为我的客户实现这一点..?

这是我想要完成的: http ://www.trails2000.org/site/trail_conditions.html

不知道该怎么办??我可以轻松地制作一张桌子并让它们更新.. ?

或者我在看 GD Star 评级并进行 Multi-set ?但也不确定..

有什么我忽略的吗?

谢谢!

4

4 回答 4

3

手动编码最适合这种情况,因此您可以更好地控制所需的功能。

并考虑使用 Post 类型构建它

   http://codex.wordpress.org/Post_Types

要了解有关自定义帖子类型的更多信息,请查看此幻灯片

http://www.slideshare.net/williamsba/custom-post-types-and-taxonomies-in-wordpress
于 2012-07-05T04:36:45.290 回答
2

不要手动操作(我通过“手动”收集,您指的是硬编码,还是让用户通过 WYSIWYG 编辑器编辑表格?)。

正如每个人所说,做它定制。您需要使用自定义帖子类型、自定义分类法和自定义字段。

如果您使用插件,您应该寻找一个管理自定义帖子类型、自定义分类法和自定义字段的插件,例如: http: //magicfields.org/

话虽如此,在没有插件的情况下手动编码并不是很困难,并且应该让您更好地了解它们是如何组合在一起的。

'Trail' 应该是自定义帖子类型。“Trail”帖子类型应该有一个自定义分类“Trail System”,它将包含“Colorado Trail System”、“Fort Lewis Trail System”等。“Trail”帖子类型应该有“condition”的自定义字段,以及可能是“评论”。虽然“评论”可以存储在帖子正文中。

客户将能够通过 Wordpress 管理界面添加“Trails”和“Trail Systems”来自行更新网站,类似于他们添加“Posts”和“Categories”的方式。

有道理?

编辑:下面解释如何使用原始代码设置上述内容(即,没有插件)

下面是一些示例代码,应该放在functions.php 中。一旦此代码在functions.php 中,“Trails”应该出现在“Posts”下方的管理界面中。“Trail Systems”应该出现在“Trails”的下拉菜单中,就像“Categories”对“Posts”所做的那样。当您添加新的“Trail”时,下面应该有“comments”和“condition”的自定义字段。

<?php 

// CREATE YOUR CUSTOM POST TYPE
add_action( 'init', 'create_custom_post_type_trail');
function create_custom_post_type_trail() {

    // Set all the labels for your custom post type, as they will appear in the wordpress admin interface.
    $labels = array( 
        'name' => _x( 'Trails', 'trail' ),
        'singular_name' => _x( 'Trail', 'trail' ),
        'add_new' => _x( 'Add New', 'trail' ),
        'add_new_item' => _x( 'Add New Trail', 'trail' ),
        'edit_item' => _x( 'Edit Trail', 'trail' ),
        'new_item' => _x( 'New Trail', 'trail' ),
        'view_item' => _x( 'View Trail', 'trail' ),
        'search_items' => _x( 'Search Trails', 'trail' ),
        'not_found' => _x( 'No Trails found', 'trail' ),
        'not_found_in_trash' => _x( 'No Trails found in Trash', 'trail' ),
        'parent_item_colon' => _x( 'Parent Trail:', 'trail' ),
        'menu_name' => _x( 'Trails', 'trail' ),
    );

    // Set all the options for your custom post type - you may need to change some of these
    $args = array( 
        'labels' => $labels,
        'hierarchical' => false,

        'supports' => array( 'title', 'editor', 'custom-fields' ),
        'taxonomies' => array(),
        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'menu_position' => 5,

        'show_in_nav_menus' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'has_archive' => true,
        'query_var' => true,
        'can_export' => true,
        'rewrite' => array('slug' => 'trails', 'with_front' => false),
        'capability_type' => 'post'
    );

    register_post_type( 'trail', $args );
}

// ADD CUSTOM FIELDS TO THE TRAIL CUSTOM POST TYPE
add_action('wp_insert_post', 'add_custom_trail_fields');

function add_custom_trail_fields($post_id) {
    if ( isset($_GET['post_type']) and $_GET['post_type'] == 'trail' ) {
        add_post_meta($post_id, 'condition', '', true);
        add_post_meta($post_id, 'comments', '', true);
    }
    return true;
}

// ADD CUSTOM TAXONOMY TO THE TRAIL CUSTOM POST TYPE
add_action( 'init', 'create_trail_taxonomies' );
function create_trail_taxonomies(){

    // Set all the labels for your custom taxonomy, as they will appear in the wordpress admin interface.
    $labels = array(
        'name' => _x( 'Trail Systems', 'taxonomy general name' ),
        'singular_name' => _x( 'Trail System', 'taxonomy singular name' ),
        'search_items' =>  __( 'Search Member Categories' ),
        'all_items' => __( 'All Member Categories' ),
        'parent_item' => __( 'Parent Trail System' ),
        'parent_item_colon' => __( 'Parent Trail System:' ),
        'edit_item' => __( 'Edit Trail System' ), 
        'update_item' => __( 'Update Trail System' ),
        'add_new_item' => __( 'Add New Trail System' ),
        'new_item_name' => __( 'New Trail System Name' ),
        'menu_name' => __( 'Trail System' ),
    ); 

    // Set all the options for your custom taxonomy - you may need to change some of these
    $args = array(
        'labels' => $labels,
        'label'=>'Trail Systems',
        'hierarchical'=>true, // this makes them behave like 'categories' as opposed to like 'tags'
        'rewrite' => array('slug' => 'trail_system', 'with_front' => false),
    );
    register_taxonomy('trail_system', 'trail', $args);

}

/*
// This is for if you make a mistake, and have to unregister a taxonomy and register it with a new name
add_action( 'init', 'unregister_taxonomy');
function unregister_taxonomy(){
    global $wp_taxonomies;
    $taxonomy = 'XXXXXXXXX'; // name of your taxonomy goes here.
    if ( taxonomy_exists( $taxonomy))
        unset( $wp_taxonomies[$taxonomy]);
}
*/


?>

您可能会发现其他一些有用的东西:

您可以通过http://www.example.com/?post_type=trailhttp://www.example.com/trail或类似的网址访问您的足迹,具体取决于您的永久链接的设置方式。

在您的主题中,您可以创建文件archive-trail.php 和single-trail.php 来为存档/单个“Trail”帖子制作自定义模板。

在 The Loop 内部,您可以像这样访问自定义帖子字段:

<?php
$fields = get_post_meta( get_the_ID()); // get all custom fields
echo $fields['comments'][0]; // display 'comments' field
echo $fields['condition'][0]; // display 'condition' field
?>

再次在 The Loop 内部,获取您的自定义分类,如下所示:

<?php 
$trail_system = get_the_terms( $post->ID, 'trail_system');
echo $trail_system;
?>

最后,我不知道您是否需要对 Trails 进行搜索,但如果需要,请查看:http ://thereforei.am/2011/10/28/advanced-taxonomy-queries-with-pretty-urls /

于 2012-07-05T05:33:55.120 回答
1

根据我的经验,定制要好得多 - 提供更大的灵活性。我经常使用插件,因为最初它为我节省了一些时间,然后 70% 的项目我不得不进行一些小的修改,最终浪费了更多的时间来弄清楚如何以及在哪里制作我本可以自己编写整个该死的东西的那些变化。

于 2012-07-05T03:02:34.097 回答
0

您可以为他们创建一个管理页面,专门为每个跟踪保存变量(“好”“坏”或其他),允许编辑或以上的用户更新它。我认为这里的自定义解决方案肯定是最好的。

如果您登录http://myego.org,然后转到“我的 EGO”页面,您会看到那种管理页面(尽管您的页面全是下拉菜单,而这个全是字段)。

于 2012-07-05T04:18:13.380 回答