Show Featured Post On Homepage Using META KEY

Share Now


<?php 
   $paged = get_query_var( "paged" )?get_query_var( "paged" ) : 1;
   $posts_per_page = -1;
   $_p = new WP_Query(array(
       'posts_per_page'    => $posts_per_page,
       'paged'             => $paged,
       'meta_query'        => array(
           'relation' => 'AND',
           array(
               'key'     => 'featured',
               'value'   => '1',
               'compare' => '=',
           ),
           array(
               'key'     => 'homepage',
               'value'   => '1',
               'compare' => '=',
           ),
       )
   ));
   while( $_p->have_posts() ):
   $_p->the_post();
   ?>




  //FEATURED POSTS TITLES
  <h3><?php the_title(  ); ?></h3>




<?php
   endwhile;
   wp_reset_query();
   ?>

Picture of Nahid Mahamud

Nahid Mahamud

Web Developer | Graphic Designer | WordPress & Woo-commerce Expert