admin管理员组文章数量:1130349
i need to show featured post on custom taxonomy page above default loop but not showing feature post its showing all post
$args = array(
'posts_per_page' => 3,
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'city',
'field' => 'term_id',
),
),
'meta_query' => array(
'key' => 'is_this_featured',
'value' => 'yes',
'compare' => 'LIKE',
),
);
$query = new WP_Query( $args );
if ( have_posts() ) :
while ( have_posts() ) : the_post();
// $ids[] = get_the_ID();
the_title();
the_content();
endwhile;
endif;
wp_reset_query();
i need to show featured post on custom taxonomy page above default loop but not showing feature post its showing all post
$args = array(
'posts_per_page' => 3,
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'city',
'field' => 'term_id',
),
),
'meta_query' => array(
'key' => 'is_this_featured',
'value' => 'yes',
'compare' => 'LIKE',
),
);
$query = new WP_Query( $args );
if ( have_posts() ) :
while ( have_posts() ) : the_post();
// $ids[] = get_the_ID();
the_title();
the_content();
endwhile;
endif;
wp_reset_query();
Share
Improve this question
edited Nov 30, 2018 at 10:44
Aniruddha Gawade
1,2131 gold badge10 silver badges12 bronze badges
asked Nov 30, 2018 at 8:32
Om PalOm Pal
11 bronze badge
1
- You can try using suppress_filters => true param in your WP_Query args list – vikrant zilpe Commented Nov 30, 2018 at 10:54
1 Answer
Reset to default 0Syntax for your meta query seems to be wrong. Just as tax query, it should be array with array for each meta condition. Also use $query for your query functions:
$args = array(
'posts_per_page' => 3,
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'city',
'field' => 'term_id',
),
),
'meta_query' => array(
array(
'key' => 'is_this_featured',
'value' => 'yes',
'compare' => 'LIKE',
),
),
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $query->the_post();
// $ids[] = get_the_ID();
the_title();
the_content();
endwhile;
endif;
wp_reset_query();
i need to show featured post on custom taxonomy page above default loop but not showing feature post its showing all post
$args = array(
'posts_per_page' => 3,
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'city',
'field' => 'term_id',
),
),
'meta_query' => array(
'key' => 'is_this_featured',
'value' => 'yes',
'compare' => 'LIKE',
),
);
$query = new WP_Query( $args );
if ( have_posts() ) :
while ( have_posts() ) : the_post();
// $ids[] = get_the_ID();
the_title();
the_content();
endwhile;
endif;
wp_reset_query();
i need to show featured post on custom taxonomy page above default loop but not showing feature post its showing all post
$args = array(
'posts_per_page' => 3,
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'city',
'field' => 'term_id',
),
),
'meta_query' => array(
'key' => 'is_this_featured',
'value' => 'yes',
'compare' => 'LIKE',
),
);
$query = new WP_Query( $args );
if ( have_posts() ) :
while ( have_posts() ) : the_post();
// $ids[] = get_the_ID();
the_title();
the_content();
endwhile;
endif;
wp_reset_query();
Share
Improve this question
edited Nov 30, 2018 at 10:44
Aniruddha Gawade
1,2131 gold badge10 silver badges12 bronze badges
asked Nov 30, 2018 at 8:32
Om PalOm Pal
11 bronze badge
1
- You can try using suppress_filters => true param in your WP_Query args list – vikrant zilpe Commented Nov 30, 2018 at 10:54
1 Answer
Reset to default 0Syntax for your meta query seems to be wrong. Just as tax query, it should be array with array for each meta condition. Also use $query for your query functions:
$args = array(
'posts_per_page' => 3,
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'city',
'field' => 'term_id',
),
),
'meta_query' => array(
array(
'key' => 'is_this_featured',
'value' => 'yes',
'compare' => 'LIKE',
),
),
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $query->the_post();
// $ids[] = get_the_ID();
the_title();
the_content();
endwhile;
endif;
wp_reset_query();
本文标签: i need to show featured post on custom taxonomy page
版权声明:本文标题:i need to show featured post on custom taxonomy page 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749138651a2321805.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论