WordPress.org

Ready to get started?Download WordPress

Forums

How to use conditional tags for homepage background (4 posts)

  1. josaphi
    Member
    Posted 2 years ago #

    Hi there, I'm very new to coding wordpress. I've installed a very nice theme (Shuttershot) but they have very few support. Basically this them uses the supersize slideshow but it appears everywhere on the site (home page, blog page,categories, etc.) I did some searching and found out about conditional tags to hide the slideshow from the rest of the site. Unfortunately I didn't find help on what/where exactly I should be using these tags. I received a snippet of some code from a forum that helps with Shuttershot but I'm not sure if the code needs some fill in the blanks and I definitely didn't receive any directions as to what files and where I should add it to. Here is what I received:
    '<?php
    if ( is_home() ) {
    // Slideshow script
    } else {
    // Some other background
    }
    ?>'

    I'm sure there is more this code but I'm not sure what. Can someone please help?! Sidebar: How can you make slides linkable to pages/categories?

  2. keesiemeijer
    moderator
    Posted 2 years ago #

    Is this the theme: http://www.fabthemes.com/shuttershot/

    Try it in your header.php. Put everything between the script tags in a conditional:

    <?php if ( !is_home() ) : ?>
    <script type="text/javascript">
    ... rest of script ...
    </script>
    <?php endif; ?>

    Not sure If this will break the layout of your site.

  3. josaphi
    Member
    Posted 2 years ago #

    Hi Keesiemeijer,

    That is the correct theme! I did as you said and the good thing is the code didn't break the site. However it wasn't working, so for some reason I thought to take out the "!" from "is_home" and it worked! The slideshow appears on the homepage and no where else! BUT now of course there is a small issue. It seems that when you go to another page the loading symbol appears as if its trying to still load the slideshow. Any work around for this? Is this something I need to get read of via css? Here is the final code I used with the script you gave:

    <?php if ( is_home() ) : ?>
    <script type="text/javascript">  
    
    	jQuery(function($){
    		$.supersized({
    
    					//Functionality
    					slideshow               :   1,		//Slideshow on/off
    					autoplay				:	1,		//Slideshow starts playing automatically
    					start_slide             :   1,		//Start slide (0 is random)
    					random					: 	0,		//Randomize slide order (Ignores start slide)
    					slide_interval          :   5000,	//Length between transitions
    					transition              :   1, 		//0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
    					transition_speed		:	1000,	//Speed of transition
    					new_window				:	1,		//Image links open in new window/tab
    					pause_hover             :   0,		//Pause slideshow on hover
    					keyboard_nav            :   1,		//Keyboard navigation on/off
    					performance				:	1,		//0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed // (Only works for Firefox/IE, not Webkit)
    					image_protect			:	1,		//Disables image dragging and right click with Javascript
    
    					//Size & Position
    					min_width		        :   0,		//Min width allowed (in pixels)
    					min_height		        :   0,		//Min height allowed (in pixels)
    					vertical_center         :   1,		//Vertically center background
    					horizontal_center       :   1,		//Horizontally center background
    					fit_portrait         	:   1,		//Portrait images will not exceed browser height
    					fit_landscape			:   0,		//Landscape images will not exceed browser width
    
    					//Components
    					navigation              :   1,		//Slideshow controls on/off
    					thumbnail_navigation    :   1,		//Thumbnail navigation
    					slide_counter           :   1,		//Display slide numbers
    					slide_captions          :   1,		//Slide caption (Pull from "title" in slides array)
    					slides 					:  	[		//Slideshow Images
    
    <?php
    // The Query
    query_posts( 'post_type=slides&posts_per_page=-1&orderby=rand' );
    $i=0;
    while ( have_posts() ) : the_post();
    $simg=get_post_meta($post->ID, 'wtf_slide', true);
    if ($i > 0) : echo ','; else: echo ''; endif; //For IE sake add a coma BEFORE every image offsetting the first one.
    echo "{image : '".$simg."'}";
    $i++;
    endwhile;
    wp_reset_query();
     ?>
    ]
    
    });
    });
    </script>
    <?php endif; ?>
  4. keesiemeijer
    moderator
    Posted 2 years ago #

    Maybe also put this in your header.php in a conditional tag:

    wp_enqueue_script('supersized', get_stylesheet_directory_uri() .'/js/supersized.3.1.3.min.js');
    if(is_home()){
    wp_enqueue_script('supersized', get_stylesheet_directory_uri() .'/js/supersized.3.1.3.min.js');
    }

Topic Closed

This topic has been closed to new replies.

About this Topic