Show Featured Post Only On The Homepage

Before the content/loop I have this featured post on the top. The problem is that it shows up in the other pages besides the home. I tried several solutions, but I am unable to hide it. Any help would be great.

<?php
$args = array(
‘posts_per_page’ => 1,
‘meta_key’ => ‘meta-checkbox’,
‘meta_value’ => ‘yes’
);
$featured = new WP_Query($args);

if ($featured->have_posts()): while($featured->have_posts()):
$featured->the_post(); ?>
<h3><a href=”<?php the_permalink(); ?>”> <?php the_title(); ?></a></h3>
<?php if (has_post_thumbnail()) : ?>

<figure> <a href=”<?php the_permalink(); ?>”><?php
the_post_thumbnail(); ?></a> </figure>
<p><?php the_excerpt();?></p>
<?php
endif;
endwhile; else:
endif;
?>

Read more here:: Show Featured Post Only On The Homepage

Leave a Reply

Your email address will not be published. Required fields are marked *