[Resolved] How to disable GP Hooks for a specific page?

Home Forums Support How to disable GP Hooks for a specific page?

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #108282
    Philippe

    Hello Tom,

    Have you a solution for disable GP Hooks on a specific page ?

    Best regards.

    #108292
    Jean

    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.

    #108305
    Tom
    Lead Developer
    Lead Developer

    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

    #108613
    Philippe

    Thank you very much to you both 🙂

    #544315
    Toby

    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

    #544561
    Leo
    Staff
    Customer Support

    Hi there,

    Hard to tell without seeing the page.

    What exactly isn’t working? Are they showing up in all the pages or none?

    #544577
    Toby

    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; ?>

    #544847
    Leo
    Staff
    Customer Support

    Need to add the array bracket as well.

    See example here: https://codex.wordpress.org/Conditional_Tags#A_PAGE_Page

    Let me know.

    #545018
    Toby

    Thanks, now I got it right! 🙂

    <?php if ( ! is_page( [6198, 11338, 11340] ) ) : ?>
    [elementor-template id=”10004″]
    <?php endif; ?>

    #545380
    Leo
    Staff
    Customer Support
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.