首页 > 解决方案 > Show posts from two specific category in WP_Query

问题描述

I've two category employee and full-time. If a post publish in both (employee and full-time) category then the post will show in his specific section. If post has only employee category, not full-time or has only full-time, not employee, then this post will not show in the post block.

How can I do this? What will be the query of this relationship between two category??

Here is my code -

'tax_query'         =>  array(
    'relation'      =>  'AND',
    array(
        'taxonomy' => 'category',
        'field'    => 'slug',
        'terms'    => array('employee', 'full-time'),
    )
)

标签: wordpresstheme-development

解决方案


推荐阅读