自定义发布类型+自定义分类=存档列表页面问题

时间:2014-01-19 作者:Mike

我有一个使用自定义分类法的自定义帖子类型。据我所知,它正在发挥作用,从某种意义上说,我可以创建一篇文章,并为其指定自定义分类术语。调试显示正在保存术语。

我想我的困惑在于模板层次结构是如何工作的。我复制了档案。php文件,并将其命名为“taxonomy-zouk\\u video\\u level.php”,现在正在调用它。但该文件中有通常的循环,当我导航到该术语的URL时,找不到帖子。

我应该使用不同的循环吗?还是我根本不使用循环?

这是我的自定义帖子类型代码:

<?php

function zouk_custom_types() { 

    $videolabels = array(
        \'name\'               => \'Videos\',
        \'singular_name\'      => \'Video\',
        \'add_new\'            => \'Add New\',
        \'add_new_item\'       => \'Add New Video\',
        \'edit_item\'          => \'Edit Video\',
        \'new_item\'           => \'New Video\',
        \'all_items\'          => \'All Videos\',
        \'view_item\'          => \'View Video\',
        \'search_items\'       => \'Search Videos\',
        \'not_found\'          => \'No Videos found\',
        \'not_found_in_trash\' => \'No Videos found in Trash\',
        \'parent_item_colon\'  => \'\',
        \'menu_name\'          => \'Videos\'
    );

    register_post_type( \'zouk_video\',
        array( 
            \'labels\' => $videolabels,
            \'description\' => __( \'A video.\', \'bonestheme\' ),
            \'public\' => true,
            \'publicly_queryable\' => true,
            \'exclude_from_search\' => true,
            \'show_ui\' => true,
            \'query_var\' => true,
            \'menu_position\' => 1,
            \'menu_icon\' => \'dashicons-editor-video\', 
            \'rewrite\'   => array( \'slug\' => \'zouk_video\', \'with_front\' => false ), 
            \'has_archive\' => \'zouk_video\',
            \'capability_type\' => \'post\',
            \'hierarchical\' => false,
            \'supports\' => array( \'title\', \'editor\', \'author\', \'thumbnail\', \'excerpt\', \'trackbacks\', \'custom-fields\', \'comments\', \'revisions\')
        )
    ); 

    $instructorlabels = array(
        \'name\'               => \'Instructors\',
        \'singular_name\'      => \'Instructor\',
        \'add_new\'            => \'Add New\',
        \'add_new_item\'       => \'Add New Instructor\',
        \'edit_item\'          => \'Edit Instructor\',
        \'new_item\'           => \'New Instructor\',
        \'all_items\'          => \'All Instructors\',
        \'view_item\'          => \'View Instructor\',
        \'search_items\'       => \'Search Instructors\',
        \'not_found\'          => \'No Instructors found\',
        \'not_found_in_trash\' => \'No Instructors found in Trash\',
        \'parent_item_colon\'  => \'\',
        \'menu_name\'          => \'Instructors\'
    );

    register_post_type( \'zouk_instructor\', 
        array( 
            \'labels\' => $instructorlabels, 
            \'description\' => __( \'An instructor.\', \'bonestheme\' ),
            \'public\' => true,
            \'publicly_queryable\' => true,
            \'exclude_from_search\' => true,
            \'show_ui\' => true,
            \'query_var\' => true,
            \'menu_position\' => 2,  
            \'menu_icon\' => \'dashicons-groups\', 
            \'rewrite\'   => array( \'slug\' => \'zouk_instructor\', \'with_front\' => false ), 
            \'has_archive\' => \'zouk_instructor\',
            \'capability_type\' => \'post\',
            \'hierarchical\' => false,
            \'supports\' => array( \'title\', \'editor\', \'author\', \'thumbnail\', \'excerpt\', \'trackbacks\', \'custom-fields\', \'comments\', \'revisions\')
        ) 
    ); 

    /* use categories with the videos */
    register_taxonomy_for_object_type( \'category\', \'zouk_video\' );

}

    // adding the above to the Wordpress init
    add_action( \'init\', \'zouk_custom_types\');

function zouk_video_types() {   

    // now custom term for video levels
    register_taxonomy( \'zouk_video_level\', \'zouk_video\',
        array(
            \'hierarchical\' => true,
            \'label\' => \'Video Levels\',
            \'show_admin_column\' => true, 
            \'show_ui\' => true,
            \'query_var\' => true,
            \'rewrite\' => array( \'slug\' => \'video-level\' ),
            \'public\' => true,
        )
    );

}

// adding the above to the Wordpress init
    add_action( \'init\', \'zouk_video_types\');

?>

1 个回复
SO网友:Mike

事实证明我需要这样做:

\'exclude_from_search\' => false
现在循环正在返回帖子。

结束

相关推荐

Order custom taxonomy by date

我有一个名为series的自定义分类法。我想有一个页面,其中列出了所有系列与最新的顶部。系列鱼类系列关于狗的系列文章我创建了一个分类学系列。php,其中列出了各个系列,但我要http://example.com/series. 我有一个404。我是否需要在主题上创建单独的页面?列出所有按日期排列的系列?