$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>i need to show featured post on custom taxonomy page|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

i need to show featured post on custom taxonomy page

matteradmin10PV0评论

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
Add a comment  | 

1 Answer 1

Reset to default 0

Syntax 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();
Post a comment

comment list (0)

  1. No comments so far