最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp query - tax_query not working on custom post type

programmeradmin1浏览0评论

For some reason my tax_query is returning 0 posts. I'm able to assign posts to the Tax and the archive pages work correctly. When I try to create the below custom query the post_count in the WP_QUERY object is 0. Please help!

TAXONOMY REGISTRATION:

register_taxonomy(  
    'member_resources_categories',  //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces). 
    'member_resources',        //post type name
    array(  
        'hierarchical' => true,  
        'label' => 'Categories',  //Display name
        'query_var' => true,
        'rewrite' => array('slug' => 'member-resource-category','with_front' => true),
        'public' => true,
        'has_archive' => 'member-resource-category',
    )  
);

WP_QUERY args:

$args = array(
    'post_type' => 'member_resources',
    'status'    => 'publish',
    'tax_query' => array(
        array(
            'taxonomy'  => 'member_resources_categories',
            'field'     => 'slug',
            'terms'     => 'background-on-tent'
        )
    )
);
发布评论

评论列表(0)

  1. 暂无评论