• Resolved dontlikecheese

    (@dontlikecheese)


    I am currently using Meteor Slider on my site (a child theme of the original Responsive by ThemeID, now Cyberchimps)and love the plug-in thank you ??
    At present, the slider shows on all pages and header.php calls for ‘featured_content’ rather than a specific slideshow

    <div id="featured-image" class="grid col-940 fit"> 
    
                <?php $options = get_option('responsive_theme_options');
    			// First let's check if image was set
    			    if (!empty($options['featured_content'])) {
    					echo do_shortcode($options['featured_content']);
    		    // If not display dummy image for preview purposes
    			      } else {
                        echo '<img class="aligncenter" src="'.get_stylesheet_directory_uri().'/images/featured-image.png" width="440" height="250" alt="" />';
     				  }
    			?> 
    
            </div>

    Now I would like to have a different slidshow which will appear instead of the general one on specific pages. What is the best way to do this?
    Thanks for your help.

    https://www.ads-software.com/plugins/meteor-slides/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Josh Leuze

    (@jleuze)

    Hi, I assuming that you have added that slideshow using the shortcode in the featured content theme option?

    So that will show sitewide, but if you want to load slideshows conditionally, like only on the homepage, or a specific slideshow on the homepage and a default on on the rest of the pages, then you need to use the slideshow template tag with conditional tags in your header.php file.

    First take that code in your post, and replace it with this:

    <div id="featured-image" class="grid col-940 fit"> 
    
       <?php if ( function_exists( 'meteor_slideshow' ) ) { meteor_slideshow(); } ?>
    
    </div>

    That should replace the slideshow shortcode that is loaded in theme options with the slideshow template tag which will load the slideshow right in the theme.

    Test that out and if that is working fine, then you can start to add some conditional logic, like this:

    <div id="featured-image" class="grid col-940 fit"> 
    
       <?php if ( function_exists( 'meteor_slideshow' ) ) {
    		if ( is_front_page() ) {
    			meteor_slideshow( "home", "" );
    		} elseif ( is_page( 'about' ) ) {
    			meteor_slideshow( "about", "" );
    		} else {
    			meteor_slideshow( "default", "" );
    		}
       } ?>
    
    </div>

    That will allow you to load multiple slideshows, first checking for the front page and loading a homepage slideshow, then checking for an about page for a about slideshow, then if it isn’t one of those pages it loads a default slideshow. From there you could edit the conditionals or add more to load a slideshow on any page.

    Thread Starter dontlikecheese

    (@dontlikecheese)

    Hi Josh,
    thank you for looking into this and for your reply. Something still isn’t working, though I am further on than before!
    So, I tried the first step and that worked fine, so I tried some conditionals as you suggested:

    <div id="featured-image" class="grid col-940 fit"> 
    
       <?php if ( function_exists( 'meteor_slideshow' ) ) {
    		if ( is_page('test-landing-page') ) {
    			meteor_slideshow( "brochure", "" );
    				}
    		 else {
    			meteor_slideshow( "general", "" );
    		}
       } ?>
    
    </div>

    So, on all the pages the ‘general’ slideshow appears, but on ‘test-landing-page’ no slideshow appears, whereas I had wanted ‘brochure’ slideshow to appear.
    I have created the slideshow called ‘brochure’, and it has 2 slides attibuted to it. Its my first go at conditional logic and am not sure where I am going wrong…
    Thanks for your help!

    Plugin Author Josh Leuze

    (@jleuze)

    It looks like you have everything correct in there. I would confirm that the page has the slug “test-landing-page”, and that it is a page and not a post or a custom post type. Also double check that the slideshow’s slug is “brochure”.

    To simplify this for testing you could try just this and make sure you can get that conditional to work before adding the slideshows:

    <?php if ( is_page( 'test-landing-page' ) ) {
    	echo 'True!';
    } ?>
    Thread Starter dontlikecheese

    (@dontlikecheese)

    Josh, you’re a genius! The slideshow slug was brochure-2. I’ve updated the code and it all works brilliantly now.
    Thank you so much for all your help ??

    Plugin Author Josh Leuze

    (@jleuze)

    You’re welcome!

    I’m trying to add a different slideshow for each page on my website but i can’t get it to work. I used the code but the problem is that on on the pages ‘ home’ and ‘breed’ it shows the default and the slideshow i specified. So two images on top of each other. How is this possible? I want only one slidehow.

    I was also wondering how the code should look like if have to add another line for a new page?
    Thanks for the help.

    This is the code is used.

    <div id="featured-image" class="grid col-940 fit"> 
    
      	 <?php if ( function_exists( 'meteor_slideshow' ) ) { meteor_slideshow(); } ?>
    		 <?php if ( function_exists( 'meteor_slideshow' ) ) {
    		if ( is_front_page() ) {
    			meteor_slideshow( "home", "" );
    		} elseif ( is_page( 'breed' ) ) {
    			meteor_slideshow( "breed", "" );
    		} else {
    			meteor_slideshow( "default", "" );
    		}
       } ?>
    
    	</div>
    Plugin Author Josh Leuze

    (@jleuze)

    @gvangelder It is showing two slideshows because you have the meteor_slideshow function in there twice for each slideshow. Once up top outside of the conditionals on this line:

    <?php if ( function_exists( 'meteor_slideshow' ) ) { meteor_slideshow(); } ?>

    And then below that in the conditionals. So what you want is this:

    <div id="featured-image" class="grid col-940 fit"> 
    
    	<?php if ( function_exists( 'meteor_slideshow' ) ) {
    		if ( is_front_page() ) {
    			meteor_slideshow( "home", "" );
    		} elseif ( is_page( 'breed' ) ) {
    			meteor_slideshow( "breed", "" );
    		} else {
    			meteor_slideshow( "default", "" );
    		}
       } ?>
    
    </div>

    You can continue to add different slideshows to new pages by adding another elseif conditional like this:

    <div id="featured-image" class="grid col-940 fit"> 
    
    	<?php if ( function_exists( 'meteor_slideshow' ) ) {
    		if ( is_front_page() ) {
    			meteor_slideshow( "home", "" );
    		} elseif ( is_page( 'breed' ) ) {
    			meteor_slideshow( "breed", "" );
    		} elseif ( is_page( 'new' ) ) {
    			meteor_slideshow( "new", "" );
    		} else {
    			meteor_slideshow( "default", "" );
    		}
       } ?>
    
    </div>
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘different sliders on different pages – featured content’ is closed to new replies.