Community Forums › Forums › Archived Forums › General Discussion › Function – Agency_post_image
Tagged: post image above post title
- This topic has 18 replies, 2 voices, and was last updated 11 years ago by genevishgraphics.
-
AuthorPosts
-
November 18, 2013 at 8:46 am #73937genevishgraphicsMember
Using Runway community theme - It is utilizing this code in functions.php to display thumbs of the posts on the front page (home page), however I am finding that it is also displaying this way on a page using wordpress's built in gallery. So now I have a duplicate large image at the top of the page, and below that is the page title and the gallery. Any suggestions on how to tweak this so it is only going to apply to the home page and not any other pages? Thanks
/** Add Post image above post title, single posts only */
http://www.greenqueen.com.hk/gq-press/
add_action( 'genesis_before_post', 'agency_post_image' );
function agency_post_image() {
if ( is_front_page() ) return;
if ( $image = genesis_get_image( 'format=url&size=post-image' ) ) {
printf( '', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
}
}November 18, 2013 at 1:37 pm #73998nutsandboltsMemberDid you get this resolved? I'm not seeing the gallery on individual posts - just the large featured image.
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+November 18, 2013 at 1:38 pm #73999genevishgraphicsMemberIts just on the press page, a large image above the title of the page, then the gallery below that.
November 18, 2013 at 1:41 pm #74000nutsandboltsMemberOkay, I see it now. If you edit that page and switch to the Text editor instead of Visual, can you paste in everything from the editor box?
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+November 18, 2013 at 1:43 pm #74001genevishgraphicsMemberSure - I have combed through and dont see the repeat image
<p>[gallery link="file" ids="7381,2492,2488,2062,2060,2059,2057,1732,1717"]</p> <p> </p> <h1>As seen on</h1> <p><a href="http://www.greenqueen.com.hk/wp-content/uploads/2011/10/logo-veggy.jpg"><img class="alignleft size-full wp-image-2565" alt="Veggy Japan" src="http://www.greenqueen.com.hk/wp-content/uploads/2011/10/logo-veggy.jpg" width="242" height="111" /></a></p> <p><a href="http://www.greenqueen.com.hk/wp-content/uploads/2011/10/playtimes.png"><img class="alignleft size-full wp-image-2564" alt="Playtimes Magazine" src="http://www.greenqueen.com.hk/wp-content/uploads/2011/10/playtimes.png" width="216" height="69" /></a></p> <p><a href="http://www.greenqueen.com.hk/wp-content/uploads/2011/10/scmp.png"><img class="alignleft size-full wp-image-2560" alt="South China Morning Post SCMP" src="http://www.greenqueen.com.hk/wp-content/uploads/2011/10/scmp.png" width="621" height="58" /></a></p> <p><a href="http://www.greenqueen.com.hk/wp-content/uploads/2011/10/sassymama.png"><img class="alignleft size-full wp-image-2559" alt="sassymama" src="http://www.greenqueen.com.hk/wp-content/uploads/2011/10/sassymama.png" width="492" height="111" /></a><img class="alignleft size-full wp-image-2547" alt="Sassy Hong Kong" src="http://www.greenqueen.com.hk/wp-content/uploads/2011/10/sassy-hk.png" width="387" height="172" /></p> <p><img class="alignleft size-full wp-image-2545" alt="Foodie Magazine" src="http://www.greenqueen.com.hk/wp-content/uploads/2011/10/foodie-magazine.png" width="252" height="144" /><img class="alignleft size-full wp-image-2550" alt="expatlivingrevamp_logo" src="http://www.greenqueen.com.hk/wp-content/uploads/2011/10/expatlivingrevamp_logo.jpg" width="520" height="154" /><img class="alignleft size-full wp-image-2574" alt="Hong Kong Tatler Dining" src="http://www.greenqueen.com.hk/wp-content/uploads/2011/10/tatler-online.png" width="261" height="112" /><img class="alignleft size-full wp-image-2561" alt="Healthy Hong Kong Blog" src="http://www.greenqueen.com.hk/wp-content/uploads/2011/10/healthyhkblog.png" width="341" height="85" /><br class="Apple-interchange-newline" /><a href="http://www.greenqueen.com.hk/wp-content/uploads/2011/10/the-list.png"><img class="alignleft size-full wp-image-2558" alt="The List Magazine" src="http://www.greenqueen.com.hk/wp-content/uploads/2011/10/the-list.png" width="387" height="116" /></a></p> <p><img class="alignleft size-full wp-image-2557" alt="hk mag asiacity_logo" src="http://www.greenqueen.com.hk/wp-content/uploads/2011/10/hk-mag-asiacity_logo.png" width="222" height="93" /><a href="http://www.greenqueen.com.hk/wp-content/uploads/2011/10/hkyantoyan.png"><img class="alignleft size-full wp-image-2555" alt="HK Yanto Yan" src="http://www.greenqueen.com.hk/wp-content/uploads/2011/10/hkyantoyan.png" width="350" height="97" /></a></p> <p><img class="alignleft size-full wp-image-2549" alt="Hip Hong Kong " src="http://www.greenqueen.com.hk/wp-content/uploads/2011/10/hhklogo.gif" width="125" height="124" /><a href="http://thehkhub.com/featured-posts/green-queens-guide-to-hong-kong/"><img class="alignleft size-full wp-image-2553" alt="thehkhub" src="http://www.greenqueen.com.hk/wp-content/uploads/2011/10/thehkhub.png" width="181" height="119" /></a><img class="alignleft size-full wp-image-2554" alt="localiiz" src="http://www.greenqueen.com.hk/wp-content/uploads/2011/10/localiiz.png" width="216" height="83" /><img class="alignleft size-full wp-image-2551" alt="little_steps_logo_all_0" src="http://www.greenqueen.com.hk/wp-content/uploads/2011/10/little_steps_logo_all_0.png" width="642" height="120" /></p>
November 18, 2013 at 1:45 pm #74002nutsandboltsMemberOkay, so it's supposed to be showing the gallery and not the large image at the top. I was thinking the opposite.
If you remove the featured image from the page, does that solve the problem? I'm guessing the page won't be showing in the homepage grid since it's a page and not a post, so there shouldn't be any reason to include a featured image.
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+November 18, 2013 at 1:48 pm #74004genevishgraphicsMemberThats just it - there is no featured image attached to the page at all - weird right?
November 18, 2013 at 1:53 pm #74005nutsandboltsMemberYeah, that's definitely weird. The page source clearly shows it with the class "post-photo". Hmmm....
The function for the featured image is already using a conditional to work on the homepage only, so that shouldn't be the problem. If you activate the Genesis Framework instead of Runway, does it still show like that?
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+November 18, 2013 at 4:47 pm #74050genevishgraphicsMemberI really dont want to switch the theme to genesis since it is a live site 🙁
November 18, 2013 at 5:48 pm #74059nutsandboltsMemberAh, I understand completely! I didn't realize the site was live.
Are you using a page template for that page, or just the default?
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+November 18, 2013 at 5:50 pm #74060genevishgraphicsMemberNope just plain old regular default - I am sure I am missing something here, or do you think it is a conflict with wp built-in gallery and the theme?
November 18, 2013 at 5:51 pm #74063nutsandboltsMemberIt shouldn't be... I use the default gallery all the time and I've never had this problem.
Try this - remove the gallery from the page (leave in all the logos at the bottom, and make sure you paste the shortcode for the gallery somewhere so you can put it back). If that takes away the giant image, I would try adding the gallery again from scratch. If it doesn't, we'll know it's nothing to do with the gallery.
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+November 18, 2013 at 6:03 pm #74068genevishgraphicsMemberHmmm I took out the gallery shortcode and it is still there. So its not the gallery its the theme. If you look at this page, I have the same issue with the featured image - it is above the title, only this time it really is a featured image, however its a page not a post, and the function is directed towards the front page only, so it shouldnt affect any other pages, right?
November 18, 2013 at 6:03 pm #74069nutsandboltsMemberOkay, good to know. Can you paste in your entire functions.php?
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+November 18, 2013 at 6:05 pm #74071genevishgraphicsMemberSeems like is is the code snippet I noted earlier - here is the full thing
<?php // Start the engine require_once( get_template_directory() . '/lib/init.php' ); // Child theme (do not remove) define( 'CHILD_THEME_NAME', 'Runway Theme' ); define( 'CHILD_THEME_URL', 'http://my.studiopress.com/themes/runway/' ); // Add Viewport meta tag for mobile browsers add_action( 'genesis_meta', 'sample_viewport_meta_tag' ); function sample_viewport_meta_tag() { echo '<meta name="viewport" content="width=device-width, initial-scale=1.0"/>'; } add_filter( 'wpbdp_form_field_html_value', 'my_mailto_filter', 10, 3 ); function my_mailto_filter( $value, $post_id, $field ) { if ( $field->has_validator('email') ) { return sprintf('<a href="mailto:%s">%s</a>', $value, $value); } return $value; } // Add support for custom background add_theme_support( 'custom-background' ); // Add support for 3-column footer widgets add_theme_support( 'genesis-footer-widgets', 3 ); // Enqueue sticky menu script add_action( 'wp_enqueue_scripts', 'custom_enqueue_script' ); function custom_enqueue_script() { wp_enqueue_script( 'sticky-menu', get_stylesheet_directory_uri() . '/js/sticky-menu.js', array( 'jquery' ), '', true ); } // Reposition the secondary navigation menu remove_action( 'genesis_after_header', 'genesis_do_subnav' ); add_action( 'genesis_before', 'genesis_do_subnav' ); // Unregister other site layouts genesis_unregister_layout( 'content-sidebar-sidebar' ); genesis_unregister_layout( 'sidebar-sidebar-content' ); genesis_unregister_layout( 'sidebar-content-sidebar' ); // Customize the post info function add_filter( 'genesis_post_info', 'post_info_filter' ); function post_info_filter($post_info) { if ( !is_page() ) { $post_info = '[post_date]'; return $post_info; }} //* Add font awesome add_action( 'wp_enqueue_scripts', 'prefix_enqueue_awesome' ); function prefix_enqueue_awesome() { wp_enqueue_style( 'prefix-font-awesome', '//netdna.bootstrapcdn.com/font-awesome/3.2.0/css/font-awesome.min.css', array(), '3.2.0' ); } // Modify the speak your mind text add_filter( 'genesis_comment_form_args', 'custom_comment_form_args' ); function custom_comment_form_args($args) { $args['title_reply'] = 'Leave a Comment'; return $args; } function make_mce_awesome( $init ) { $init['theme_advanced_text_colors'] = '72bf44,ec0080'; return $init; } add_filter('tiny_mce_before_init', 'make_mce_awesome'); /** Add Post image above post title, single posts only */ add_action( 'genesis_before_post', 'agency_post_image' ); function agency_post_image() { if ( is_front_page() ) return; if ( $image = genesis_get_image( 'format=url&size=post-image' ) ) { printf( '<a href="%s" rel="bookmark"><img class="post-photo" src="%s" alt="%s" /></a>', get_permalink(), $image, the_title_attribute( 'echo=0' ) ); } } // Add News Widget Area register_sidebar( array( 'id' => 'news', 'name' => __( 'News', 'runway' ), 'description' => __( 'This is the news section.', 'runway' ), ) ); add_action( 'genesis_before', 'runway_news_genesis' ); /** * Add news widget support for site. If widget not active, don't display * */ function runway_news_genesis() { genesis_widget_area( 'news', array( 'before' => '<div class="news widget-area">', ) ); } // Add Slider Widget Area genesis_register_sidebar( array( 'id' => 'home-featured', 'name' => __( 'Home Featured', 'runway' ), 'description' => __( 'This is the widget area for the Genesis Responsive Slider.', 'runway' ), ) ); /** Custom image sizes */ add_image_size( 'Grid', 200, 200, TRUE ); add_image_size( 'Featured-Home', 750, 500, TRUE );
November 18, 2013 at 6:13 pm #74073nutsandboltsMemberAh, I don't know why I didn't see that before - that function is actually saying "Don't do this on the homepage, but only on single posts."
You could remove the function (which would also remove the featured image on posts) or you could alter it to exclude pages:
/** Add Post image above post title, single posts only */ add_action( 'genesis_before_post', 'agency_post_image' ); function agency_post_image() { if ( is_front_page() || is_page() ) return; if ( $image = genesis_get_image( 'format=url&size=post-image' ) ) { printf( '<a href="%s" rel="bookmark"><img class="post-photo" src="%s" alt="%s" /></a>', get_permalink(), $image, the_title_attribute( 'echo=0' ) ); } }
Note - that's untested (I don't have Runway loaded on any of my test sites) so there's the potential for something to break if my syntax is wrong. Be sure you have FTP or CPanel access to functions.php before you try that in case it needs to be changed back. If it doesn't work, let me know and I'll load the theme and try before I start pasting code in here. 🙂
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+November 18, 2013 at 6:19 pm #74075genevishgraphicsMemberWorked great, whew! I just knew it had something to do with that function, still learning conditional statements 🙂
Thanks for sticking around to help!!November 18, 2013 at 6:21 pm #74076nutsandboltsMemberNo problem! Sorry it took so long - this could have been solved 10 posts ago if I'd been reading carefully enough.
If you don't mind, please mark this topic as resolved so we'll know you've been helped. 🙂
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+November 18, 2013 at 6:23 pm #74077genevishgraphicsMemberThanks!!
-
AuthorPosts
- The topic ‘Function – Agency_post_image’ is closed to new replies.