- This topic has 5 replies, 3 voices, and was last updated 4 years ago by
Leo.
-
AuthorPosts
-
February 16, 2017 at 2:57 pm #279949
David
I’m looking to add a slider to the header of a website, where the slider sits above the primary menu. When adding the short code to the content section (Header add-on), the slider appears below the menu (i.e. the page has a header image, the menu and then the slider). How can I add the slider so it replaces the header image?
Once this is achieved, I am hoping to add a different header image to the top of each page. For example:
Page 1 = SmartSlider >> menu
Page 2 = header image 2 >> menu
Page 3 = header image 3 >> menu
etc.Probably something simple, but any help will be appreciated.
Thank you
February 16, 2017 at 3:09 pm #279950Leo
StaffCustomer SupportHi David,
I think using GP hooks is your best bet here.
https://docs.generatepress.com/article/hooks-overview/
http://demo.generatepress.com/hook-locations/So in Appearance > GP Hooks > Before Header Content, try something like this:
<?php if ( is_page( 'home-page-slug' ) ) { ?> Slider shortcode here <?php } elseif ( is_page( 'page-slug-1' ) ) { ?> Image #1 <?php } elseif ( is_home() ) { ?> Image for blog page <?php } else { ?> Image for all other pages <?php } ?>
Make sure Execute PHP is checked.
Let me know.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/February 17, 2017 at 8:05 am #280209Jasper
So for all pages except homepage is used this:
<?php } elseif ( is_home() ) { ?>
<?php } else { ?>
[elementor-template id=”74″]
<?php endif; ?>But that does not work, unfortunately
February 17, 2017 at 8:24 am #280220Leo
StaffCustomer SupportCan you answer my question here and stick with one post please.
https://generatepress.com/forums/topic/after-content-hook-content-only-after-posts/#post-280206Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/February 17, 2017 at 11:20 am #280318David
Thank you for the quick reply. I added the following to the ‘Before Header Content’ field and enabled PHP for that option.
<?php if ( is_page( ‘home-page-slug’ ) ) { ?>
[smartslider3 slider=2]
<?php } elseif ( is_page( ‘page-slug-1’ ) ) { ?>
Image #1
<?php } elseif ( is_home() ) { ?>
Image for blog page
<?php } else { ?>
Image for all other pages
<?php } ?>Unfortunately, this had the same effect as if I added just the short code to the field. thank you for your help.
February 17, 2017 at 2:37 pm #280374Leo
StaffCustomer SupportHi David,
You need to replace some contents in the code I provided above in order for it to work. Basically like how you replaced “Slider shortcode here” with “[smartslider3 slider=2]”.
Without seeing your site I can’t actually give you the code explicitly.I edited the code slightly below to help you understand. You need to replace everything in capital letters.
The assumption here is also that your home page is not the blog page, let me know if this assumption is wrong.<?php if ( is_front_page() ) { ?> [smartslider3 slider=2] <?php } elseif ( is_page( 'PAGE-SLUG-1' ) ) { ?> <img src="http://PAGE-1-IMAGE-URL-HERE" /> <?php } elseif ( is_page( 'PAGE-SLUG-2' ) ) { ?> <img src="http://PAGE-2-IMAGE-URL-HERE" /> <?php } else { ?> <img src="http://ALL-OTHER-PAGES-IMAGE-URL" /> <?php } ?>
If you still can’t get it to work, it might be easier to show me the site.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.