Black Friday Sale! Get up to $30 off GP Premium! Learn more ➝

[Resolved] Hook question

Home Forums Support [Resolved] Hook question

Home Forums Support Hook question

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #244955
    mc208

    I’m using this plugin: https://wordpress.org/plugins/insert-pages/
    to insert a custom footer I made with Elementor, via shortcode into the “before footer content” hook location so that it inserts the layout on all the pages. However, I have a need to NOT display the footer on particular page. Is there some way that I can exclude certain pages from having the content displayed in that hook location?

    #245017
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    You would have to use a PHP conditional: https://codex.wordpress.org/Conditional_Tags

    For example:

    <?php if ( ! is_page( 'my-excluded-page-slug' ) ) : ?>
        <?php echo do_shortcode( '[your-shortcode]' ); ?>
    <?php endif; ?>
    #245045
    Lyle

    … or, you could use Tom’s fantastic Simple CSS plugin and then on the page you do not want that custom footer to appear on, just add some CSS to the meta box in the WP editor.

    .insert-page.insert-page-18 {
    display: none;
    }

    You get the page from Appearance > Pages > All Pages and hovering over the Page where you created the footer; it will show the ID in the lower left of your screen.

    May not be as eloquent, but a lot “safer” than wrangling PHP πŸ™‚

    Cheers!
    Lyle

    http://snifflevalve.com
    Tutorials and tips for GeneratePress, WP Show Posts, WordPress and Elementor

    #245061
    Tom
    Lead Developer
    Lead Developer

    That’s actually a better idea, especially if there will be multiple pages to hide it from.

    Thanks, Lyle!

    #245284
    mc208

    A third party added a plugin this morning:
    http://www.elementoraddons.com/anywhere-elementor/
    because there were issues with using the insert pages plugin method.

    So now, I still use a shortcode, but it’s via this other plugin and it uses the post ID, not the slug. So Tom, can I still use your PHP conditional, and how would I write it if I wanted to exclude more than one page?

    Thanks

    #245320
    Tom
    Lead Developer
    Lead Developer

    You would add an array inside the is_page function:

    <?php if ( ! is_page( array( 'my-excluded-page-slug', 'another-page', 'one-more' ) ) ) : ?>
        <?php echo do_shortcode( '[your-shortcode]' ); ?>
    <?php endif; ?>

    Alternatively, wrap your shortcode in a div with a class, and hide it using CSS using Lyle’s method.

    #245336
    Lyle

    Mike –

    Make it easy for yourself … no PHP will be harmed πŸ™‚ Use Tom’s Simple CSS plugin and add this to the pages where you don’t want the footer:

    #elementor.elementor.elementor-18 {
    display: none;
    }

    This is using the new plugin that you link to above πŸ™‚ Note that you have to use your own ID for the Elementor created page ID.

    Cheers!
    Lyle

    http://snifflevalve.com
    Tutorials and tips for GeneratePress, WP Show Posts, WordPress and Elementor

    #245357
    mc208

    Is there anything you DON’T know? That worked!

    #332970
    John

    I have a similar problem, I have two headers I want to use GP hooks with, at the moment I am using anywhere elementor to insert in GP Hooks. What I want to do is when the visitor logs into the site it shows one header when they are logged out it shows the other. I have tried playing around with some of the examples on here but to no avail.
    Any help anyone?

    #332985
    Lyle

    John –

    Just tried this and it works πŸ™‚ Adjust the IDs to your own of course. The 440 id is the Anywhere Elementor template ID for logged in users and 444 is for logged out users (visitors).

    Paste this into the appropriate GP Hook location and don’t forget to tick the Execute PHP tick box.

    <`?php
    if ( is_user_logged_in ( ) ) {
    echo do_shortcode( ‘[INSERT_ELEMENTOR id=440]’ );
    } else {
    echo do_shortcode( ‘[INSERT_ELEMENTOR id=444]’ );
    }
    ?>`

    Cheers!
    Lyle

    http://snifflevalve.com
    Tutorials and tips for GeneratePress, WP Show Posts, WordPress and Elementor

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