[Resolved] Hook on first page only

Home Forums Support [Resolved] Hook on first page only

Home Forums Support Hook on first page only

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #101159
    Kit Marsden

    Hi,

    I have some code in the GP Hook which shows on my homepage (as a ‘Welcome’ bit which is static and displays above the posts which show on the homepage). I am wondering whether there is a piece of code I can use to make sure this only displays on the first page of the homepage – ie. if somebody scrolls to the bottom and clicks onto Page 2 to read older posts, they don’t need to see the ‘Welcome’ message any more, and so it will only display on the first page?

    Thanks,
    Kit Marsden

    #101263
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Using the following PHP should work: https://gist.github.com/generatepress/ef11bf8ff3a5292a9922

    Be sure to check the “Execute PHP” checkbox.

    Hope this helps πŸ™‚

    #102214
    Kit Marsden

    Thanks, Tom – that’s perfect!

    #102300
    Tom
    Lead Developer
    Lead Developer

    You’re welcome πŸ™‚

    #427979
    Scott

    Is there a way to make this code work with WP Show Posts? My home page is a list of latest posts displayed by WP Show Posts with pagination at the end.

    I would like my welcome message to show only on the first page.

    Many thanks.

    #428079
    Leo
    Staff
    Customer Support

    Hi Scott,

    You should be able to something like this:

    <?php is_front_page() ) : ?>
        Code here
    <?php endif; ?>

    if this doesn’t help can you open a topic for your question?

    Thanks!

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.