- This topic has 14 replies, 2 voices, and was last updated 8 years, 4 months ago by
Tom.
-
AuthorPosts
-
April 23, 2015 at 9:48 am #101604
Mike Tolliver
Hi Tom,
I downloaded the Cosmo Slider Plugin from Slidervilla and am trying to get a slider to take up the entire width of the page (example here). Their customer support indicated that they actually have a snippet of php to add to a template to make it do this very thing:
<?php if(function_exists(“get_cosmo_slider”)){get_cosmo_slider($slider_id=”1″,$set=”1″);}?>
I have been trying to figure out how to add this to a home page template so that I dont have to burn one of my other templates to make it do this. Do you have a suggestion for how to make this work?
April 23, 2015 at 9:55 am #101620Tom
Lead DeveloperLead DeveloperDo you have GP Hooks?
If so, you could do this in the “After Header” hook (or wherever):
<?php if ( is_front_page() ) : ?> <?php if(function_exists("get_cosmo_slider")){get_cosmo_slider($slider_id="1",$set="1");}?> <?php endif; ?>
That would include your slider on the homepage, below your header, full width.
Be sure to check the “Execute PHP” checkbox.
Let me know if you have any questions π
April 24, 2015 at 9:22 am #101950Mike Tolliver
Hey Tom,
I do have GP Hooks, and that worked like a charm. However, I decided I could not do nearly enough with the Cosmo Slider and went and got Master Slider instead. Way happier with that, but now I am trying to figure out how to do the same thing. I think it will be a similar strategy you outlined above, but I took a swing at the code and couldnt get it to work. They say in their documentation (here) that you can add a slider in the manner you suggested by adding this php:
<?php masterslider ( $slider_id ); ?>
OR
<?php echo get_masterslider ( $slider_id ); ?>
Any thoughts on how I might adapt the code you gave me above to make this slider work?
Thanks again!
April 24, 2015 at 10:47 am #102034Tom
Lead DeveloperLead DeveloperIt should just be something like this:
<?php if ( is_front_page() ) : ?> <?php if(function_exists("masterslider")) { masterslider( 1 ); } ?> <?php endif; ?>
“1” being the ID of your slider.
April 24, 2015 at 12:12 pm #102045Mike Tolliver
Yes, that has put the slider on the home page. The problem is that I have fixed my header and footer and I would like the slider to entirely fill the space in between. Currently I have disabled all of the elements between the two, but there is still a space that is scrollable. Also, the slider currently loads with about 1/6th of the slider hidden by the header.
Any thoughts?
April 24, 2015 at 2:30 pm #102065Tom
Lead DeveloperLead DeveloperWhich hook are you adding it to?
Can you link me to the page so I can take a look?
Thanks!
April 25, 2015 at 8:04 am #102291Mike Tolliver
I put the code in the “After Header” hook.
I have to keep my page locked down until it is compliance approved (I work in finance), but I can private message you the code to get in and see it. What is the best way to send it to you?
April 25, 2015 at 10:15 am #102319Tom
Lead DeveloperLead DeveloperYou can send it to me at support@generatepress.com π
April 26, 2015 at 11:35 pm #102650Tom
Lead DeveloperLead DeveloperHmm tough one, I’m not sure it’s possible to set the slider to be 100% height of the browser without some pretty custom javascript – unless of course the plugin has that option built in.
As for the content hiding behind the header, that’s because when you fix an element, the rest of the element can’t see it.
You’ll have to find the exact height of your header and navigation, and then add this CSS to create enough spacing to show all of your content:
@media (min-width: 769px) { body { padding-top: 150px; } }
The 150px being whatever the height of your header is.
April 27, 2015 at 11:42 am #102892Mike Tolliver
Okay, that fixed the spacing underneath the header. And it turns out my slider actually does have a “fit to width” option that automatically resizes the height to fit. I think the final thing to do to make this work is figure out how to disable all other elements between the header and footer on this page. I have used your ‘Disable Elements’ extension to remove the Post Image/Page Header and Headline/Post Title elements, but there is still a space left below the slider that seems to include the text/content box and any spacing associated with its inclusion on a page. Can we remove those elements so it is just the slider?
April 27, 2015 at 11:47 pm #103057Tom
Lead DeveloperLead DeveloperGive this a try:
.home .container { display: none; }
April 28, 2015 at 10:35 am #103351Mike Tolliver
That worked like a charm! Final question:
If I wanted to remove the container on select pages or posts without adding that css to an entire template, how would I do that?
April 28, 2015 at 10:38 pm #103553Tom
Lead DeveloperLead DeveloperYou’ll need to add the CSS regardless, but you can target specific pages with their body class.
For example, you can target the homepage like this:
.home .container { display: none; }
Or specific pages by their ID, like this:
.page-id-xx .container { display: none; }
xx would be the ID of the page.
Let me know if you need more info π
April 29, 2015 at 3:09 pm #103918Mike Tolliver
Okay that worked great, but I actually do have another question (sorry!). The CSS worked, but when I tried to add the slider after the header on that same page using:
<?php if ( is_page-id-xx() ) : ?>
<?php if(function_exists(“masterslider”)) {
masterslider( 2 );
} ?>
<?php endif; ?>It didnt work. Thoughts?
April 29, 2015 at 7:16 pm #103948Tom
Lead DeveloperLead Developer<?php if ( is_page-id-xx() ) : ?>
is incorrect.It should be:
<?php if ( is_page('xx') ) : ?>
More info on conditionals here: https://codex.wordpress.org/Conditional_Tags
-
AuthorPosts
- You must be logged in to reply to this topic.