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.

$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>
endwhile; else:

With the help of Castiblanco I solved this!

if( !is_paged() ) {

// Your code! 

}; ?>
  • If you want you can mark this question as solved. – Castiblanco Jul 9 '18 at 1:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.