Archived topic
Masking GP Hooks on all but Homepage
13 replies · Started by Cassie Thomas on May 3, 2015
Hi Tom,
I have a GP Hook on my homepage that is currently housing a shortcode gallery right above my footer. Is there a way that I can mask this hook so it only shows on my homepage?
Thanks,
Cassie
http://www.AmherstHall.com
Wrap it in a PHP if conditional:
<?php if ( is_front_page() ) : ?>
Anything in here will only show up on the homepage.
<?php endif; ?>
Make sure you check the "Execute PHP" checkbox.
Great Thanks!
You're welcome! :)
Thanks! Where do I find the “Execute PHP” checkbox in Wordpress?
Hi Oliver
Did you add the code to GP hooks? If yes then you can find the execute php checkbox right beneath where you added the code.
Thanks for your answer!But doesenst although I clicked the "execute php buttom" I got the following error message:
Parse error: syntax error, unexpected 'if' (T_IF) in C:\wamp\www\wp-content\plugins\generate-hooks\functions\hooks.php(19) : eval()'d code on line 2
What should I do?
Thanks for your help
Ivo
What's the exact code you added into the hook?
It was my fault. I forgot to insert the link into the PHP Code.
It works. Great.
Thanks!
Awesome :)
What about the opposite? I want to show a shortcode included in a GPHook in all pages but home page. I mean, I don´t want to show the shortcode in the home, cause I am using a transparent header, but I want the shortcode appears in the rest of the site
See examples here: https://docs.generatepress.com/article/using-hooks-conditional-tags/
Great!!! Done!!!
Thanks Leo
No problem!
