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();