[Resolved] Hooks Issue with conditional tags

Home Forums Support [Resolved] Hooks Issue with conditional tags

Home Forums Support Hooks Issue with conditional tags

  • This topic has 11 replies, 2 voices, and was last updated 6 years ago by Leo.
Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #550715
    Manuel

    Hi,

    I´m trying to do the following.

    I have a template header only for homepage and a template header for the rest of the pages and my conditional tags work fine as follows:

    <?php if ( is_front_page() ) : ?>
    [elementor-template id=”17″]
    <?php endif; ?>
    <?php if ( ! is_front_page() ) : ?>
    [elementor-template id=”125″]
    <?php endif; ?>

    Now I have a specific Landing Page and I don´t want to display on that page none of those templates, I have tried with this Tag:
    <?php if ( ! is_page( 7400) ) : ?>
    [elementor-template id=”125″]
    <?php endif; ?>

    but it doesn’t work as it displays twice the template.

    Thanks for your help.

    #550938
    Leo
    Staff
    Customer Support

    Hi there,

    I believe this is what you are after:

    <?php if ( ! is_front_page() || ! is_page( 7400) ) : ?>
        [elementor-template id=”125″]
    <?php endif; ?>

    Let me know.

    #550948
    Manuel

    No,

    the secondary header still appears. This are my hooks now:

    <?php if ( is_front_page() ) : ?>
    [elementor-template id=”17″]
    <?php endif; ?>
    <?php if ( ! is_front_page() ) : ?>
    [elementor-template id=”125″]
    <?php endif; ?>
    <?php if ( ! is_front_page() || ! is_page( 7400 ) ) : ?>
    [elementor-template id=”125″]
    <?php endif; ?>

    #550996
    Leo
    Staff
    Customer Support

    This should be your overall code:

    <?php if ( is_front_page() ) : ?>
        [elementor-template id="17"]
    <?php endif; ?>
    <?php if ( ! is_front_page() && ! is_page( 125 ) ) : ?>
        [elementor-template id="125"]
    <?php endif; ?>
    #551043
    Manuel

    Sorry, but still doesn’t work, nothing changed.

    #551207
    Leo
    Staff
    Customer Support

    Hmm I just tested and it should work.

    Can you link me to the page that isn’t working?

    #552083
    Manuel
    #552128
    Leo
    Staff
    Customer Support

    The ID of that page is 7400 so you will have to modify my code accordingly:
    https://generatepress.com/forums/topic/hooks-issue-with-conditional-tags/#post-550996

    Or did you already do that?

    #552355
    Manuel

    Hi, yes I tried also with the ID Number but the result was the same.

    #552828
    Leo
    Staff
    Customer Support

    Just to make sure, this is your overall snippet?

    <?php if ( is_front_page() ) : ?>
        [elementor-template id="17"]
    <?php endif; ?>
    <?php if ( ! is_front_page() && ! is_page( 7400 ) ) : ?>
        [elementor-template id="125"]
    <?php endif; ?>

    And execute PHP is checked?

    #552965
    Manuel

    Now is working ok. Thanks a lot.

    #552971
    Leo
    Staff
    Customer Support

    No problem!

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