0

So for long articles, I like to break them up into multiple pages using the page break function, however, if I do this the featured image appears on the extra pages. Is there any way to stop this from happening? I was trying to do something along the lines of:

<?php if (!is_paged()) {?>
<?php }?>

Can anyone point me in the right direction?

Here is the full code for context:

<?php if (!is_paged()) {?>
                        <?php if ( get_post_format() ) { get_template_part('inc/post-formats'); } else { if ( has_post_thumbnail() ): ?>
                            <?php if ( ot_get_option('single_featured') != 'off' ) { ?>
                                <div class="mbf">
                                <div class="image-container" itemprop="image">
                            <?php the_post_thumbnail('full'); ?>
                            <?php 
                                $caption = get_post(get_post_thumbnail_id())->post_excerpt;
                                $description = get_post(get_post_thumbnail_id())->post_content;
                                if ( isset($caption) && $caption ) echo '<div class="caption">'.$caption.'</div>';
                            ?>
                                </div>
                            <?php if ( isset($description) && $description ) echo '<div class="description mt"><i>'.$description.'</i></div>'; ?>
                            </div>
                        <?php } endif; } ?>
                        <?php }?>
  • Regarding your updated code snippet, it's not working? Please elaborate – birgire Nov 11 '16 at 10:44
  • No, it still shows the featured image on extra pages. The page is here: elitegamer.ie/review-overwatch-razer-gaming-gear/2 – Daire Nov 11 '16 at 10:45
  • What's the value of get_query_var( 'page' ) ; does it change ? – birgire Nov 11 '16 at 11:00
0

You can try to check the page query variable, used by the contant pagination, with:

if( 0 === (int) get_query_var( 'page' ) )
{
    // show post thumbnail
}

The core function is_paged() checks for the paged query variable.

  • I'm not sure if I can do it that way, i have added the sections code for context above. – Daire Nov 11 '16 at 10:40
  • Updated the answer – birgire Nov 11 '16 at 13:26

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.