Community Forums › Forums › Archived Forums › Design Tips and Tricks › Slider on home, other pages to pull featured image.
Tagged: Agency, featured image, genesis, slider
- This topic has 9 replies, 2 voices, and was last updated 10 years, 6 months ago by KarenLeighBurton.
-
AuthorPosts
-
August 28, 2013 at 10:43 am #59239KarenLeighBurtonMember
I am working on a site http://www.readyvillemill.com
We have an area set at the top of each page that currently displays the "genesis responsive slider". My client would like the slider itself to only appear on the homepage, but when you visit a page or post the "featured image" from that page (if none assigned then by default display the slider) in that location.
I'm sure it's some code that just needs to go into either the functions or the home.php (or both) but I am not a very strong php coder. Can someone help me with this functionality?
It would be much appreciated.
Thank you 🙂
http://www.readyvillemill.comAugust 28, 2013 at 11:38 am #59251Sridhar KatakamParticipantPlace a file named page.php having this code in agency directory: http://pastebin.com/3cVnBf3V
That should do it.
August 28, 2013 at 12:05 pm #59260KarenLeighBurtonMemberThank you - 🙂
That works - but it is still running the slider so it now has the slider on top and the featured image below;
http://www.readyvillemill.com/about/any additional suggestions?
August 28, 2013 at 12:11 pm #59263Sridhar KatakamParticipantThat is strange, it doesn't work like that in the test site on my localhost. Hopefully someone more experienced can chime in.
August 28, 2013 at 12:13 pm #59265KarenLeighBurtonMembernevermind! I think I may have figured it out and fixed it - woohoo!
Thank you very much.August 28, 2013 at 12:23 pm #59272Sridhar KatakamParticipantAugust 28, 2013 at 12:46 pm #59277KarenLeighBurtonMemberwell I created a special widget area called welcome-text in the theme which was assigned to "all pages/posts/home" etc. I figured out I needed to acutally use the home-slider widget section for the slideshow - once i moved the slideshow there it worked. I did have to apply a div to the featured image so that it just wasn't left aligned on the top of the page.
I made this edit to the page.php code;
<?php
add_action( 'genesis_after_header', 'agency_home_welcome_helper' );
function agency_home_welcome_helper() {
echo '<div id="home-welcome">';
if (has_post_thumbnail( $post->ID ) ) :
echo get_the_post_thumbnail($post->ID);
echo '</div><!-- end #home-welcome -->';else :
if ( is_active_sidebar( 'home-slider' ) ) :
echo '<div id="home-slider">';
dynamic_sidebar( 'home-slider' );
echo '</div><!-- end #home-slider -->';endif;
endif;
}
genesis();
October 1, 2013 at 7:57 pm #65031KarenLeighBurtonMemberSridhar, Wondering if you know how to do this same thing on an un-modified version of eleven40 (not the pro). I want to use the page-title widget area to display a slider or image on the homepage, but then on all pages/posts pull the featured image - if none revert to the homepage image. I've asked, I've even tried what you provided above and it's not working...
its a development site so no url to publish - Child - Eleven40 vs 1.1 Genesis - vs 2.0.1
I've made no other modifications to this theme at all yet - figured I'd start with this first... Would greatly appreciate if you can help.
I put this in a page.php template in the theme folder;
<?php
add_action( 'genesis_before_content_sidebar_wrap', 'eleven40_page_title' );
function eleven40_page_title() {
if (has_post_thumbnail( $post->ID ) ) :
echo get_the_post_thumbnail($post->ID);else :
if ( is_active_sidebar( 'page-title' ) ) :
echo '<div id="page-title">';
dynamic_sidebar( 'page-title' );
echo '</div><!-- end #page-title -->';endif;
endif;
}
genesis();
October 5, 2013 at 1:23 am #65435Sridhar KatakamParticipantOctober 5, 2013 at 10:27 am #65475KarenLeighBurtonMemberOM Gosh - this is awesome! Thank you so very very much!
-
AuthorPosts
- The topic ‘Slider on home, other pages to pull featured image.’ is closed to new replies.