Community Forums › Forums › Archived Forums › General Discussion › Wrong Image on Custom Post Types
Tagged: Custom Post Type, featured image problem
- This topic has 3 replies, 2 voices, and was last updated 10 years, 11 months ago by Susan.
-
AuthorPosts
-
February 20, 2013 at 4:34 am #21607marjwyattMember
Theme Framework: Genesis v1.9.1
I wrote a custom post type to render display of member details captured through a gravity form. The thumbnails in archive listings are properly choosing the featured image but the output on the single page is taking the most recently uploaded image. I'm a little baffled by this so I hope someone can help.
Here is the code for the custom post type
/*
* Single Post Template: WSG Members Single
*///remove_action('genesis_post_title', 'genesis_do_post_title');//We're not using the title for this post type
remove_action('genesis_loop', 'genesis_do_loop');//remove genesis loop
add_action('genesis_loop', 'wsg_members_single_loop');//add the wsg members single loop/* Manipulate the featured image */
add_action( 'genesis_post_content', 'wsg_intro_post_image', 8 );function wsg_intro_post_image() {
if ( is_page() )
return; // Make pages act normal//setup thumbnail image args to be used with genesis_get_image();
$size = 'intro-image'; // Change this to whatever add_image_size you want
$default_attr = array(
'class' => "alignright attachment-$size $size",
'alt' => $post->post_title,
'title' => $post->post_title,
);// This is the most important part! Checks to see if the post has a Post Thumbnail assigned to it. You can delete the if conditional if you want and assume that there will always be a thumbnail
if ( has_post_thumbnail() ) {
printf( '<a title="%s" href="%s">%s</a>', get_permalink(), the_title_attribute( 'echo=0' ), genesis_get_image( array( 'size' => $size, 'attr' => $default_attr ) ) );
}}
function wsg_members_single_loop() {
//$value = get_gf_field_value($leadid, $fieldid, $form);
//http://wordpress.org/support/topic/plugin-gravity-forms-directory-accessing-form-data-for-output-in-single-entries?replies=15
$queryone = new WP_Query( array( 'post_type' => 'wsg-intros', 'posts_per_page' => '1' ) ); ?>
<h1><?php echo get_the_title(); ?></h1>
<?php $i=0; ?>
<?php while ( ($queryone->have_posts()) && ($i == 0) ) : $queryone->the_post(); ?>
<?php if ($i <= 0) { ?>
<div class="wsg-members-content">
<?php//use the genesis_get_custom_field template tag to display each custom field value ?>
<?php wsg_intro_post_image(); ?>
<p class="wsg-members-content">Date I Joined WSG: <?php echo genesis_get_custom_field('date_joined'); ?></p>
<p class="wsg-members-content">I was born on: <?php echo genesis_get_custom_field('date_birth'); ?></p>
<p class="wsg-members-content">I grew up in: <?php echo genesis_get_custom_field('grew_up'); ?></p>
<p class="wsg-members-content">My schools and majors:<br><?php echo genesis_get_custom_field('schools_majors'); ?></p>
<p class="wsg-members-content">My family information:<br><?php echo genesis_get_custom_field('family_info'); ?></p>
<p class="wsg-members-content">My past professions and activities:<br><?php echo genesis_get_custom_field('professions_activities'); ?></p>
<p class="wsg-members-content">What I'm doing now:<br><?php echo genesis_get_custom_field('doing_now'); ?></p>
<p class="wsg-members-content">Other fundraising activities and charities:<br><?php echo genesis_get_custom_field('fundraising_charities'); ?></p>
<p class="wsg-members-content">Something you don't know about me:<br><?php echo genesis_get_custom_field('something_unknown'); ?></p>
<p class="wsg-members-content">My favorite travel destination:<br><?php echo genesis_get_custom_field('fav_travel'); ?></p>
<p class="wsg-members-content">My favorite restaurant:<br><?php echo genesis_get_custom_field('fav_restaurant'); ?></p>
<p class="wsg-members-content">My Favorite lunch spot:<br><?php echo genesis_get_custom_field('fav_lunch'); ?></p>
<p class="wsg-members-content">Place to meet friends for a night out:<br><?php echo genesis_get_custom_field('night_out'); ?></p>
<p class="wsg-members-content">My favorite book, movie or play:<br><?php echo genesis_get_custom_field('book_movie'); ?></p>
<p class="wsg-members-content">My favorite place to take out of towners:<br><?php echo genesis_get_custom_field('out_of_towners'); ?></p>
<div align="center"><?php if(function_exists('pf_show_link')){echo pf_show_link();} ?></div>
</div><!--end #specials -->
<?php }; ?>
<?php $i++; ?>
<?php endwhile; ?>
<?php
};I found this link and added the code to functions.php to no avail:
http://austinpassy.com/snippets/wordpress/reset-all-posts-featured-images/Besides, since the thumbnails are properly assigned in the archives, it seems more likely that something is amiss with the function in my custom post template.
Any advice would be appreciated. Thanks in advance.
Virtually Marj Wyatt
VirtuallyMarj.com | Twitter | Facebook | Google +April 7, 2013 at 8:22 am #33696SusanModeratorHi, Marj: As you wrote this a while ago, I thought I would check in to see if you got your issue resolved?
April 7, 2013 at 10:17 am #33719marjwyattMemberA very long time ago. I figured it out on my own and that project is delivered and paid for now.
Thanks for checking in though.
Virtually Marj Wyatt
VirtuallyMarj.com | Twitter | Facebook | Google +April 7, 2013 at 10:32 am #33722SusanModeratorThanks for letting me know! I will close this as "resolved".
-
AuthorPosts
- The topic ‘Wrong Image on Custom Post Types’ is closed to new replies.