自定义帖子类型的类别列表页面

问题描述:

我将自定义帖子类型添加到名为Projects的主题中。它使用内置的类别分类,但无法获得前端列出的项目类别帖子。自定义帖子类型的类别列表页面

这里是我的,我用来创建自定义文章类型

// Register Custom Post Type 

功能custom_post_type(){

$labels = array(
    'name'    => 'Projects', 
    'singular_name'  => 'Project', 
    'menu_name'   => 'Projects', 
    'parent_item_colon' => 'Parent Item:', 
    'all_items'   => 'All Items', 
    'view_item'   => 'View Item', 
    'add_new_item'  => 'Add New Item', 
    'add_new'    => 'Add New', 
    'edit_item'   => 'Edit Item', 
    'update_item'   => 'Update Item', 
    'search_items'  => 'Search Item', 
    'not_found'   => 'Not found', 
    'not_found_in_trash' => 'Not found in Trash', 
); 
$args = array(
    'label'    => 'projects', 
    'description'   => 'Project Description', 
    'labels'    => $labels, 
    'supports'   => array('title', 'editor', 'excerpt', 'thumbnail',), 
    'taxonomies'   => array('category', 'post_tag'), 
    'hierarchical'  => false, 
    'public'    => true, 
    'show_ui'    => true, 
    'show_in_menu'  => true, 
    'show_in_nav_menus' => true, 
    'show_in_admin_bar' => true, 
    'menu_position'  => 5, 
    'can_export'   => true, 
    'has_archive'   => true, 
    'exclude_from_search' => false, 
    'publicly_queryable' => true, 
    'capability_type'  => 'page', 
); 
register_post_type('projects', $args); 

您需要查询所有帮助表示赞赏代码您的帖子类型如:$query = new WP_Query('post_type=projects');

我甚至会建议t您可以为自己的帖子类型创建一个简码,该自定义查询将会发布并列出帖子。

你可以找到更多herehere

+0

Thanks flowb0b。这样查询会打破常规分页,这已经是主题的一部分,或者我可以继续使用现有分页? – tosca 2015-01-28 10:18:54

+0

我建议在短代码中加入你的分页。类似的问题在这里:http://*.com/questions/11430392/wordpress-pagination-in-a-shortcode – schliflo 2015-01-28 12:13:28