Hi there, I'm a beginner and am trying to display wp_content_slider on the home page only and display the standard header on the rest of the site. At first it was displaying the slider then the header image underneath, now I'm getting an unexpected T_ENDIF error message for the line with "end check for featured image or standard header". Any help would be much appreciated!! <?php // Check to see if the header image has been removed $header_image = get_header_image(); if ( ! empty( $header_image ) ) : ?> <a href="<?php //echo esc_url( home_url( '/' ) ); ?>"> <?php if(is_front_page()) { if(function_exists('wp_content_slider')) { wp_content_slider(); } } else { // 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 : ?> <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" /> <? endif; ?> <?php endif; // end check for featured image or standard header ?> </a> <?php endif; // end check for removed header image ?> PHP:
That's an ugly piece of code I reformatted it to look like <?php // Check to see if the header image has been removed $header_image = get_header_image(); if ( ! empty( $header_image ) ) : ?> <a href="<?php //echo esc_url( home_url( '/' ) ); ?>"> <?php if(is_front_page()) { if(function_exists('wp_content_slider')) { wp_content_slider(); } } else { // 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 : ?> <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" /> <? endif; ?> <?php } // end check for featured image or standard header ?> </a> <?php endif; // end check for removed header image ?> PHP: They have mixed and matched the style for the if statements and tried to finish one off with an endif when it should have been braces. Try this version.
There's some short tagging - <? instead of <?php. If short tags aren't enabled on the server your code is running on, that'll throw a fatal error.
That worked, THANK YOU!!! Sorry I don't know why it came up weird when I pasted it into the message... So was it just the bracket instead of the extra endif that was missing?
yes, that's right. always happy to help our neighbours across the ditch. Just don't get too cocky with the RWC