0

Thank you in advance for any help! What I am trying to do is remove a template part from my home page after the user clicks on the pagination links from the posts, right now my template part serves as a "hero" or "featured" area, and I would like it to go away when the user looks at older posts, eg the pagination, here is what I am doing so far and it is not working, thanks!

<?php if( is_home() || is_front_page() ) : ?>
 <?php get_template_part( 'hero' ); ?>
<?php else : ?>
 <?php get_template_part( 'blank' ); ?>
<?php endif; ?>

as you can see i created a blank template , not sure if this was necessary , does it need to be inside the loop? thank you!

0

I believe what you need is is_page().

if (is_paged()) {
  // page 2 or later of an archive
} else {
  // only the first page of an archive
}

With your code, I think but am not 100% sure, that you want:

if( !is_paged() && ( is_home() || is_front_page() ) ) :
 get_template_part( 'hero' );
else :
 get_template_part( 'blank' );
endif;
0

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.