Community Forums › Forums › Archived Forums › General Discussion › Hook Help: Extend Photo Across Page
Tagged: conditional, executive pro, extend image, hooks
- This topic has 16 replies, 3 voices, and was last updated 8 years, 6 months ago by
jrotem.
-
AuthorPosts
-
April 29, 2015 at 4:02 pm #149545
jrotem
ParticipantHello,
I've tried a few version so hooks with conditional tags over the past week to get what I want but so far none have worked for me, so I hope someone can advise.I am working on a website, where I want a different photo on each static page to extend across the page (similar to her home page), above the content and sidebar. I managed to find the right hook, but only for the same photo on each page. Client wants a different photo on each static page.
I understand that would need conditional tags, yes? The few I have found on this forum and elsewhere aren't working for me. (Maybe it's theme-dependent? I'm using Executive Pro.)
I'd be very appreciative of anyone's help!
Site under development is http://www.new.darrylepollack.com.Thank you in advance,
Jean Roth
http://rotemstudio.com
“It’s always something.” — Rosanne Roseannadanna
April 29, 2015 at 5:49 pm #149559Brad Dalton
ParticipantApril 29, 2015 at 8:36 pm #149570jrotem
ParticipantThank you, Brad.
Right now it's 6, maybe 7 if the client wants to include the blog archive page (and does not include the home page, which is fine as is.) So the author page will have a photo relating to that, artist page will have art, and so forth. I'm a Genesis hooks/conditional/snippets newbie, but not afraid of hacking css or adding stuff to functions.php.I tested putting an image in the genesis_before_content hook (I don't know if it should be that or genesis_after_content_sidebar_wrap Hook, frankly.)
I tried playing with your suggestions here: http://www.studiopress.community/topic/full-width-images-education-theme/
and another one I saw on this forum, as well as one Phillip Gledhill has on his site, but I couldn't get them to work.Best,
Jean
“It’s always something.” — Rosanne Roseannadanna
April 30, 2015 at 3:52 am #149577upthink
ParticipantI think what you need is to use Featured Images. Each page can have a different featured image which you can set within the page. Then in the hook where you are currently calling a static image - do something like this:
if ( has_post_thumbnail() ) { the_post_thumbnail(); }
April 30, 2015 at 12:32 pm #149645jrotem
ParticipantThank you for the idea. Problem is that I am already using the Featured Image for homepage middle widgets which have drastically different aspect ratios. ( I tried using a 1140px wide image as a Featured Image and when I assigned them to the home widgets I cannot set precisely where I want it to crop, therefore they have to be different images-- one long one for fill width and one square.
“It’s always something.” — Rosanne Roseannadanna
April 30, 2015 at 9:48 pm #149688upthink
ParticipantIf you are already using the featured image then I suggest you take the route of using a Custom Field - checkout a plugin to help you with that - such as https://wordpress.org/plugins/advanced-custom-fields/
Once you have the field created - then use the value of the field to place the image wherever you want
May 5, 2015 at 12:22 am #150161jrotem
ParticipantI tried using Custom Fields. I got as far as creating the image field and placing the image in the new filed on the page.
But I have no idea what to put in functions.php nor how to specify where the image goes.Why fields and not hooks? When is it best to use one or the other?
“It’s always something.” — Rosanne Roseannadanna
May 5, 2015 at 1:08 am #150163upthink
ParticipantI suggested using Custom Field because you are already using the Featured Image elsewhere and need a different image on each page/post.
Looking here - http://new.darrylepollack.com/about-darryle/
I think you almost have it right - just make sure that the code for the image source runs as a php snippet and not as an html text (like it is right now) and I think you should be good.May 5, 2015 at 1:35 am #150166jrotem
ParticipantThank you , Mr Upthink.
I tested putting an ACF short code in a different hook but that didn't work. I wonder if the code i put in functions.php is correct.
I tried this short code (plus a few others I no longer remember, lol) ; would this be a php snippet?:
" alt="" />
This is the code I added to functions.php:
add_action( 'genesis_entry_header', 'custom_field_before_content', 15 );
function custom_field_before_content() {
if ( is_singular(array( 'post', 'page')) && genesis_get_custom_field('page_top_image') ) :
echo '<div class="page_top_image">'. genesis_get_custom_field('page_top_image') .'</div>';
endif;
}Am I totally off-base? I'm just trying to apply what I'm seeing in other discussions. It may not fit my needs.
“It’s always something.” — Rosanne Roseannadanna
May 5, 2015 at 1:54 am #150169upthink
ParticipantPlease copy the code by enclosing it in the code tags of the forum editor - I think some of it did not come through right because of that
May 5, 2015 at 1:56 am #150170jrotem
ParticipantLike this?
<img src="<?php the_field('page_top_image'); ?>" alt="" />
“It’s always something.” — Rosanne Roseannadanna
May 5, 2015 at 2:09 am #150171upthink
ParticipantYes this is correct. The code you have was supposed to be in an appropriate hook in your theme. I think you have used it in your content area. If you do want to put it in your content area then use this instead:
[acf field="{page_top_image}"]
May 5, 2015 at 2:15 am #150172jrotem
ParticipantI want it to appear in the genesis_before_content Hook.
Or maybe the genesis_before_content_sidebar_wrap Hook -- I am not sure what the difference will be when displayed.I did input your short code, but still no image showing. Do I tick Execute Shortcodes on this hook or Execute PHP on this hook, or both? Could that be why it's not showing?
Thank you again!
“It’s always something.” — Rosanne Roseannadanna
May 5, 2015 at 3:29 am #150178jrotem
ParticipantAlso, is this correct to place in the functions.php?
add_action( 'genesis_before_content', 'custom_field_before_content'); function custom_field_before_content() { if ( is_singular(array( 'post', 'page')) && genesis_get_custom_field('page_top_image') ) : echo '<div class="page_top_image">'. genesis_get_custom_field('page_top_image') .'</div>'; endif; }
“It’s always something.” — Rosanne Roseannadanna
May 5, 2015 at 9:17 pm #150308upthink
ParticipantAssuming that the custom field you created is page_top_image - then it seems correct.
May 5, 2015 at 10:09 pm #150312jrotem
ParticipantThank you. But no photo is showing. I must be missing something somewhere.
“It’s always something.” — Rosanne Roseannadanna
May 13, 2015 at 7:29 pm #152118jrotem
ParticipantHello, I just wanted to thank you both again for your help and to update the solution I used: Genesis Customer Headers. Plugin is easy, works a charm; only problem is how it displays in the admin, but I can live with that.
But I'm wondering what the custom field solution would have given me that would be better?
Anyway, in case someone is looking for this kind of tweak, this might do the trick for you.
“It’s always something.” — Rosanne Roseannadanna
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.