我有一个客户想要一个博客、一个新闻版面和一个“更多帖子”版面来发布感觉良好的社区服务类帖子。我在博客中使用了标准的帖子类型,一切都很好。我用这个代码注册了另外两个帖子类型,这个代码在custom_posts();
我添加的函数add_action( \'init\', \'custom_posts\');
register_post_type( \'press\',
// let\'s now add all the options for this post type
array( \'labels\' => array(
\'name\' => __( \'Press\', \'bonestheme\' ),
\'singular_name\' => __( \'Press\', \'bonestheme\' ),
\'all_items\' => __( \'All Press\', \'bonestheme\' ),
\'add_new\' => __( \'Add New\', \'bonestheme\' ),
\'add_new_item\' => __( \'Add New Post\', \'bonestheme\' ),
\'edit\' => __( \'Edit\', \'bonestheme\' ),
\'edit_item\' => __( \'Edit Post\', \'bonestheme\' ),
\'new_item\' => __( \'New Post\', \'bonestheme\' ),
\'view_item\' => __( \'View Post\', \'bonestheme\' ),
\'search_items\' => __( \'Search Posts\', \'bonestheme\' ),
\'not_found\' => __( \'Nothing found in the Database.\', \'bonestheme\' ),
\'not_found_in_trash\' => __( \'Nothing found in Trash\', \'bonestheme\' ),
\'parent_item_colon\' => \'\'
),
\'description\' => __( \'Press\', \'bonestheme\' ),
\'public\' => true,
\'publicly_queryable\' => true,
\'exclude_from_search\' => false,
\'show_ui\' => true,
\'query_var\' => true,
\'menu_position\' => 8,
\'rewrite\' => array( \'slug\' => \'press-posts\' ),
\'has_archive\' => true,
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'supports\' => array( \'title\', \'thumbnail\', \'excerpt\', \'revisions\', \'sticky\', \'custom-fields\', \'editor\', \'author\' )
)
);
register_post_type( \'more_posts\',
array( \'labels\' => array(
\'name\' => __( \'More Posts\', \'bonestheme\' ),
\'singular_name\' => __( \'Post\', \'bonestheme\' ),
\'all_items\' => __( \'All Posts\', \'bonestheme\' ),
\'add_new\' => __( \'Add New\', \'bonestheme\' ),
\'add_new_item\' => __( \'Add New Post\', \'bonestheme\' ),
\'edit\' => __( \'Edit\', \'bonestheme\' ),
\'edit_item\' => __( \'Edit Post\', \'bonestheme\' ),
\'new_item\' => __( \'New Post\', \'bonestheme\' ),
\'view_item\' => __( \'View Post\', \'bonestheme\' ),
\'search_items\' => __( \'Search Posts\', \'bonestheme\' ),
\'not_found\' => __( \'Nothing found in the Database.\', \'bonestheme\' ),
\'not_found_in_trash\' => __( \'Nothing found in Trash\', \'bonestheme\' ),
\'parent_item_colon\' => \'\'
),
\'description\' => __( \'More Posts\', \'bonestheme\' ),
\'public\' => true,
\'publicly_queryable\' => true,
\'exclude_from_search\' => true,
\'show_ui\' => true,
\'query_var\' => true,
\'menu_position\' => 9,
\'rewrite\' => array( \'slug\' => \'more-posts\' ),
\'has_archive\' => true,
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'supports\' => array( \'title\', \'thumbnail\', \'excerpt\', \'revisions\', \'sticky\', \'custom-fields\', \'editor\', \'author\' ),
)
);
我正在使用此代码添加分类法,也在
custom_posts();
功能:
register_taxonomy( \'press_cat\',
array(\'press\'), /* if you change the name of register_post_type( \'press\', then you have to change this */
array(\'hierarchical\' => true, /* if this is true, it acts like categories */
\'labels\' => array(
\'name\' => __( \'Categories\', \'bonestheme\' ), /* name of the custom taxonomy */
\'singular_name\' => __( \'Press Category\', \'bonestheme\' ), /* single taxonomy name */
\'search_items\' => __( \'Search Press Categories\', \'bonestheme\' ), /* search title for taxomony */
\'all_items\' => __( \'All Press Categories\', \'bonestheme\' ), /* all title for taxonomies */
\'parent_item\' => __( \'Parent Press Category\', \'bonestheme\' ), /* parent title for taxonomy */
\'parent_item_colon\' => __( \'Parent Press Category:\', \'bonestheme\' ), /* parent taxonomy title */
\'edit_item\' => __( \'Edit Press Category\', \'bonestheme\' ), /* edit custom taxonomy title */
\'update_item\' => __( \'Update Press Category\', \'bonestheme\' ), /* update title for taxonomy */
\'add_new_item\' => __( \'Add New Press Category\', \'bonestheme\' ), /* add new title for taxonomy */
\'new_item_name\' => __( \'New Press Category Name\', \'bonestheme\' ) /* name title for taxonomy */
),
\'show_admin_column\' => true,
\'show_ui\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'press-posts-category\' )
)
);
register_taxonomy( \'more_cat\',
array(\'more_posts\'), /* if you change the name of register_post_type( \'more-posts\', then you have to change this */
array(\'hierarchical\' => true, /* if this is true, it acts like categories */
\'labels\' => array(
\'name\' => __( \'Categories\', \'bonestheme\' ), /* name of the custom taxonomy */
\'singular_name\' => __( \'Post Category\', \'bonestheme\' ), /* single taxonomy name */
\'search_items\' => __( \'Search Posts Categories\', \'bonestheme\' ), /* search title for taxomony */
\'all_items\' => __( \'All Posts Categories\', \'bonestheme\' ), /* all title for taxonomies */
\'parent_item\' => __( \'Parent Posts Category\', \'bonestheme\' ), /* parent title for taxonomy */
\'parent_item_colon\' => __( \'Parent Posts Category:\', \'bonestheme\' ), /* parent taxonomy title */
\'edit_item\' => __( \'Edit Posts Category\', \'bonestheme\' ), /* edit custom taxonomy title */
\'update_item\' => __( \'Update Posts Category\', \'bonestheme\' ), /* update title for taxonomy */
\'add_new_item\' => __( \'Add New Posts Category\', \'bonestheme\' ), /* add new title for taxonomy */
\'new_item_name\' => __( \'New Posts Category Name\', \'bonestheme\' ) /* name title for taxonomy */
),
\'show_admin_column\' => true,
\'show_ui\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'more-posts-category\' )
)
);
Press - 使用自定义permalinks时,存档被破坏(404)(可与std perma配合使用)
More - 使用自定义permalinks时,存档被破坏(404)(可与std perma配合使用)
More - category给了我一个页面,但没有返回任何帖子(其中有2篇帖子)
我正在使用this 插件在侧边栏上创建存档和类别列表,它似乎运行正常。它提供给我的URL是:
/新闻/2015/02/-新闻档案
/more\\u posts/2015/02/-更多存档
/更多帖子类别/回馈/-更多类别