Archived topic
How to disable GP Hooks for a specific page?
9 replies · Started by Philippe on May 16, 2015
Hello Tom,
Have you a solution for disable GP Hooks on a specific page ?
Best regards.
Hey Philippe, try this:
<?php if ( is_page(X) ) return; ?>
You can place this before the content of each hook that you have. Make sure to check "Execute PHP".
The X value inside the "is_page(X)" is the ID of the page that you don't want to show the hook.
Good idea, Jean! I haven't though of using return like that in the hooks.
Another option is to use !.
For example, if your page ID is "10", and you want the hook to display on all pages but that one, you would do this:
<?php if ( ! is_page( 10 ) ) : ?>
Stuff in here will display on all pages except page ID 10.
<?php endif; ?>
All WP conditionals can be used in GP Hooks: http://codex.wordpress.org/Conditional_Tags
Thank you very much to you both :)
I'm trying to disable my custom menu using GP Hooks for 3 specific pages, but it won't work.
<?php if ( ! is_page( 6198, 11338, 11340 ) ) : ?>
[elementor-template id="10004"]
<?php endif; ?>
What am I doing wrong?
All the best,
T
Hi there,
Hard to tell without seeing the page.
What exactly isn't working? Are they showing up in all the pages or none?
Hi Leo,
Thanks for fast reply.
I use this hook to have my custom menu (Elementor, id: 10004) show up on all pages, except for:
id: 6198 = index page
id: 11338 = landing page
id: 11340 = landing page
The menu is disabled on my index page but they are showing up on my landings pages.
This works:
<?php if ( ! is_page( 6198 ) ) : ?>
[elementor-template id=”10004″]
<?php endif; ?>
This works:
<?php if ( ! is_page( 11338 ) ) : ?>
[elementor-template id=”10004″]
<?php endif; ?>
This don't:
<?php if ( ! is_page( 6198, 11338, 11340 ) ) : ?>
[elementor-template id=”10004″]
<?php endif; ?>
Need to add the array bracket as well.
See example here: https://codex.wordpress.org/Conditional_Tags#A_PAGE_Page
Let me know.
Thanks, now I got it right! :)
<?php if ( ! is_page( [6198, 11338, 11340] ) ) : ?>
[elementor-template id="10004"]
<?php endif; ?>
No problem.