質問

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;
?>
役に立ちましたか?

解決

With the help of Castiblanco I solved this!

<?php
if( !is_paged() ) {

// Your code! 

}; ?>
ライセンス: CC-BY-SA帰属
所属していません wordpress.stackexchange
scroll top