Quantcast
Channel: WordPress | サポートフォーラム »投稿一覧
Viewing all articles
Browse latest Browse all 1358

sticky_postsのポスト郡をtax_queryで絞り込めない

$
0
0

下記のように、先頭固定表示の投稿郡から、タクソノミーの値で更に絞り込みたかったのですが、
$query->found_postsでは正しく絞り込んだ件数が出るのに、実際にループで吐き出すと、先頭固定表示の全件が出力されてしまいます。

‘post__in’ => get_option(‘sticky_posts’)と’tax_query’ は組み合わせられないのでしょうか。

$args = array(
‘post_type’ => XXX,
‘posts_per_page’ => -1,
‘post__in’ => get_option(‘sticky_posts’),
‘tax_query’ => array(
‘relation’ => ‘AND’,
array(
‘taxonomy’ => ‘color’,
‘field’ => ‘slug’,
‘terms’ => ‘blue’,
‘operator’ => ‘IN’,
)
)
);
$query = new WP_Query($args);

$query->found_posts;
・・・(tax_queryの条件で絞り込まれた数が出力される)

while ($query->have_posts()):$query->the_post();
-中略-
endwhile;
・・・(tax_queryの条件は無視したsticky_posts全件が出力される。


Viewing all articles
Browse latest Browse all 1358

Trending Articles