WordPress |具有自定义发布类型的半复杂模板/后层次结构

时间:2013-07-06 18:11:05

标签: wordpress custom-post-type

我正在开发一个相当复杂的投资组合WP主题,我似乎无法找出为内容设置层次结构的逻辑和最有效的方法。内容需要深层次结构,我需要面包屑和菜单才能工作。自定义帖子类型(CPT)用于“客户端工作”,理想情况下,它将是工作>>的子页面。客户>>客户端(CPT)在默认的Pages结构中。但我无法为CPT定义父页面。我相应地改写了slug,但这似乎没有维持父/子关系。

目前,我的结构如下:

工作>客户>>客户>>>客户工作(CPT)>>>单一工作项

我的问题是: 1.有更好的方法来构建它吗? 2.我不应该使用CPT,或者我如何将CPT添加到更多的层次结构中,以便它们与各自的父母相关?

这是我的CPT注册码:

class cpt_client_work {

function cpt_client_work() {
    add_action('init',array($this,'create_post_type'));
}

function create_post_type() {
    $labels = array(
    'name' => 'Client Work',
    'singular_name' => 'Client',
    'add_new' => 'New Client Work',
    'all_items' => 'All Client Work',
    'add_new_item' => 'New Client Work',
    'edit_item' => 'Edit Client Work',
    'new_item' => 'New Client Work',
    'view_item' => 'View Client Work',
    'search_items' => 'Search Client Work',
    'not_found' =>  'No Client Work found',
    'not_found_in_trash' => 'No Client Work found in trash',
    'parent_item_colon' => 'Parent Client:',
    'parent' => 'Client',
    'menu_name' => 'Client Work'
    );
    $args = array(
        'labels' => $labels,
        'description' => "Client Work",
        'public' => true,
        'exclude_from_search' => false,
        'publicly_queryable' => true,
        'show_ui' => true, 
        'show_in_nav_menus' => true, 
        'show_in_menu' => true,
        'show_in_admin_bar' => true,
        'menu_position' => 20,
        'menu_icon' => get_bloginfo('template_directory') . '/_/images/admin-icon.png',
        'capability_type' => 'post',
        'hierarchical' => true,
        'rewrite' => array('slug' => 'work/client'),
        'supports' => array('page-attributes','title','editor','thumbnail','excerpt','custom-fields','revisions','author'),
        'has_archive' => true,
        'query_var' => true,
        'can_export' => true
    ); 
    register_post_type('cpt_client_work',$args);
}
 }

0 个答案:

没有答案