WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to insert slide show in home page header only in 2011 theme (7 posts)

  1. masooda
    Member
    Posted 1 year ago #

    I am trying to put a meteor (Plugin) slide show in the home page header only and do not want this slide show to appear on other pages. Also I want to keep the other pages headers with their own static image. Please help, I have been trying this for a while and it is driving me nuts.

  2. alchymyth
    Forum Moderator
    Posted 1 year ago #

    wrap the code into a conditional statement using the is_home() or is_front_page() conditional tags;

    http://codex.wordpress.org/Conditional_Tags

  3. masooda
    Member
    Posted 1 year ago #

    Thank you for your help, can you please tell me in which file should I put this code and in which line exactly, because I tried to insert this code in the child theme header file before <nav id="access" role="navigation"> but it didn't work.

  4. alchymyth
    Forum Moderator
    Posted 1 year ago #

    please post the full code of your attempt;

    what exactly did not work an what ways?

    what exact slide plugin are you using? (download link?)

  5. masooda
    Member
    Posted 1 year ago #

    ok I tried this code in the twenty eleven child theme header.php

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

    just above this line in the header.php in child theme
    <nav id="access" role="navigation">

    I am really hoping for a solution to this problem

  6. alchymyth
    Forum Moderator
    Posted 1 year ago #

    sligtly adapted:

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

    this should in theory show the slideshow on the front page in addition to the header image.

    to switch between slideshow and header image, you will need to edit this whole section:

    <?php
    				// Check to see if the header image has been removed
    				$header_image = get_header_image();
    				if ( $header_image ) :
    					// Compatibility with versions of WordPress prior to 3.4.
    					if ( function_exists( 'get_custom_header' ) ) {
    						// We need to figure out what the minimum width should be for our featured image.
    						// This result would be the suggested width if the theme were to implement flexible widths.
    						$header_image_width = get_theme_support( 'custom-header', 'width' );
    					} else {
    						$header_image_width = HEADER_IMAGE_WIDTH;
    					}
    					?>
    			<a href="<?php echo esc_url( home_url( '/' ) ); ?>">
    				<?php
    					// The header image
    					// Check if this is a post or page, if it has a thumbnail, and if it's a big one
    					if ( is_singular() && has_post_thumbnail( $post->ID ) &&
    							( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( $header_image_width, $header_image_width ) ) ) &&
    							$image[1] >= $header_image_width ) :
    						// Houston, we have a new header image!
    						echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
    					else :
    						// Compatibility with versions of WordPress prior to 3.4.
    						if ( function_exists( 'get_custom_header' ) ) {
    							$header_image_width  = get_custom_header()->width;
    							$header_image_height = get_custom_header()->height;
    						} else {
    							$header_image_width  = HEADER_IMAGE_WIDTH;
    							$header_image_height = HEADER_IMAGE_HEIGHT;
    						}
    						?>
    					<img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="" />
    				<?php endif; // end check for featured image or standard header ?>
    			</a>
    			<?php endif; // end check for removed header image ?>

    for example change it to:

    <?php <?php if ( is_front_page() && function_exists( 'meteor_slideshow' ) ) { meteor_slideshow(); }
    else { ?>
    			<?php
    				// Check to see if the header image has been removed
    				$header_image = get_header_image();
    				if ( $header_image ) :
    					// Compatibility with versions of WordPress prior to 3.4.
    					if ( function_exists( 'get_custom_header' ) ) {
    						// We need to figure out what the minimum width should be for our featured image.
    						// This result would be the suggested width if the theme were to implement flexible widths.
    						$header_image_width = get_theme_support( 'custom-header', 'width' );
    					} else {
    						$header_image_width = HEADER_IMAGE_WIDTH;
    					}
    					?>
    			<a href="<?php echo esc_url( home_url( '/' ) ); ?>">
    				<?php
    					// The header image
    					// Check if this is a post or page, if it has a thumbnail, and if it's a big one
    					if ( is_singular() && has_post_thumbnail( $post->ID ) &&
    							( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( $header_image_width, $header_image_width ) ) ) &&
    							$image[1] >= $header_image_width ) :
    						// Houston, we have a new header image!
    						echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
    					else :
    						// Compatibility with versions of WordPress prior to 3.4.
    						if ( function_exists( 'get_custom_header' ) ) {
    							$header_image_width  = get_custom_header()->width;
    							$header_image_height = get_custom_header()->height;
    						} else {
    							$header_image_width  = HEADER_IMAGE_WIDTH;
    							$header_image_height = HEADER_IMAGE_HEIGHT;
    						}
    						?>
    					<img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="" />
    				<?php endif; // end check for featured image or standard header ?>
    			</a>
    			<?php endif; // end check for removed header image ?>
    
    <?php } //ends the conditional statement for the slider ?>
  7. masooda
    Member
    Posted 1 year ago #

    Thanks a lot for helping me. It is working, now this slideshow is appearing only in home page header, the rest of the pages are not displaying meteor slideshow. The code portion that you told me to change to, that didn't work but when I just added this code that you suggested:

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

    This worked great!
    now I have to figure out how to show static images in the rest of page headers.
    Thanks again

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.