- This topic has 4 replies, 2 voices, and was last updated 5 years, 6 months ago by
Lyle.
-
AuthorPosts
-
November 22, 2016 at 6:31 pm #246841
Lyle
Hi Tom.
In this topic, https://generatepress.com/forums/topic/hook-question , you posted some PHP for excluding a number of pages for the display of a shortcode. Works fine π
However, I am using the following to do something similar, except this is to display one shortcode on a couple pages and another on one page. The code below works fine in the GP Hooks but I am a bit puzzled (doesn’t take much π ) about the syntax when compared to yours. Yours has more PHP tags enclosing the echo statements, etc. I found the syntax I used on Stack Overflow, so I am just wondering if it is ‘legit’ π
<?php if ( is_page( array( 'services', 'about' ) ) ) { echo do_shortcode( '[INSERT_ELEMENTOR id=115]' ); } else { echo do_shortcode( '[INSERT_ELEMENTOR id=21]' ); } ?>
Cheers!
Lylehttp://snifflevalve.com
Tutorials and tips for GeneratePress, WP Show Posts, WordPress and ElementorNovember 22, 2016 at 8:04 pm #246866Tom
Lead DeveloperLead DeveloperNothing wrong with that at all.
I think the only difference is I used
!
as in “do not include” on these pages.Your syntax looks good π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 22, 2016 at 8:09 pm #246869Lyle
Thanks, Tom π
Yep, the
!
(not) is one of the very few PHP operators I do know πJust wanted to make sure as I am about to create a tutorial based upon this to show how to switch page headers in the GP Theme that have been created with Elementor by placing this in the GP Hooks Before Header Content hook location. Works slick π
Cheers!
Lylehttp://snifflevalve.com
Tutorials and tips for GeneratePress, WP Show Posts, WordPress and ElementorNovember 22, 2016 at 9:10 pm #246874Tom
Lead DeveloperLead DeveloperAwesome! π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 22, 2016 at 9:20 pm #246879Lyle
Here it is π
Here is one that will get your GeneratePress/GP Premium “thinking cap” in a twirl π
How does switching your site header based upon the page name sound to you?
Thought so. Enjoy π
http://snifflevalve.com
Tutorials and tips for GeneratePress, WP Show Posts, WordPress and Elementor -
AuthorPosts
- You must be logged in to reply to this topic.