好的,根据法典,如果你使用tax_query
在WP\\u Query的参数中,它将更改post_type
从…起posts
到any
, 但如果post\\u类型exclude_from_search
设置为true
那么它仍然不会包括在any
. 因此,由于我们不知道portfolio post\\u类型上的配置是什么,我建议您明确指示查询搜索这两种类型posts
还有你的portfolio_post_type
.
$args = array(
//you\'ll need to put in the correct post-type for your portfolio items.
//the codex says that if you use \'tax_query\' that post_type should default to \'any\'
//but for the sake of it, try this...
\'post_type\' => array( \'posts, portfolio_post_type\' ),
\'post_status\' => \'publish\',
\'posts_per_page\' => -1,
\'orderby\' => \'date\',
\'tax_query\' => array(
\'relation\' => \'OR\',
array(
\'relation\' => \'AND\',
array(
\'taxonomy\' => \'category\',
\'field\' => \'term_id\',
\'terms\' => array( 16 ),
\'operator\' => \'IN\'
),
array(
\'taxonomy\' => \'category\',
\'field\' => \'term_id\',
\'terms\' => array( 19 ),
\'operator\' => \'NOT IN\'
),
),
array(
\'relation\' => \'AND\',
array(
\'taxonomy\' => \'portfolio_category\',
\'field\' => \'term_id\',
\'terms\' => array( 32 ),
\'operator\' => \'IN\'
),
array(
\'taxonomy\' => \'portfolio_category\',
\'field\' => \'term_id\',
\'terms\' => array( 34 ),
\'operator\' => \'NOT IN\'
),
),
),
);
以下是《法典》中讨论这一点的章节:
https://developer.wordpress.org/reference/classes/wp_query/#post-type-parameters衷心希望这能有所帮助。