- This topic has 9 replies, 4 voices, and was last updated 6 years, 10 months ago by Lyle.
-
AuthorPosts
-
November 16, 2016 at 2:28 pm #244955mc208
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?November 16, 2016 at 8:14 pm #245017TomLead DeveloperLead DeveloperHi 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; ?>
November 16, 2016 at 10:42 pm #245045Lyle… 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!
LyleNovember 17, 2016 at 12:15 am #245061TomLead DeveloperLead DeveloperThat’s actually a better idea, especially if there will be multiple pages to hide it from.
Thanks, Lyle!
November 17, 2016 at 11:47 am #245284mc208A 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
November 17, 2016 at 1:02 pm #245320TomLead DeveloperLead DeveloperYou 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.
November 17, 2016 at 2:01 pm #245336LyleMike –
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!
LyleNovember 17, 2016 at 2:54 pm #245357mc208Is there anything you DON’T know? That worked!
June 13, 2017 at 8:29 am #332970JohnI 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?June 13, 2017 at 8:54 am #332985LyleJohn –
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 -
AuthorPosts
- You must be logged in to reply to this topic.