admin管理员组文章数量:1309971
I have a loop that displays three custom post types.
Thing is, all of these post types use a different logic. 'elemzesek' and 'gyorshirek' use ACF fields which you can see in the meta_query.
However, the 'cikkek' post type, to display the correct articles, would need a
'tag' => get_the_title();
The problem is, if this is added, and it runs for 'elemzesek' and 'gyorshirek' as well, the loops finds no results.
Can someone help me in achieving this?
<?php
$ceg = get_the_title();
$ceg_megadasa = get_field('ceg_megadasa');
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$query = new WP_Query( array(
'post_type' => array('cikkek', 'elemzesek', 'gyorshirek'),
'posts_per_page' => 10,
'paged' => $paged,
'post_status' => 'publish',
// 'tag' => $ceg,
'orderby' => 'date',
'order' => 'DESC',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'ceg_megadasa',
'value' => get_the_ID()
),
array(
'key' => 'ceg_megadasa_gyorshirek',
'value' => get_the_ID()
),
)
) );
?>
本文标签: Change query based on post type while staying in loop
版权声明:本文标题:Change query based on post type while staying in loop 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741851255a2401084.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论