Archived topic
Hook on first page only
5 replies · Started by Kit Marsden on April 22, 2015
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
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 :)
Thanks, Tom – that's perfect!
You're welcome :)
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.
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!