Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

replace post thumbnail code with custom field image WordPress

  • SOLVED

the code below is from advanced custom fields and shows just one image from images uploaded to the post.
<?php $gallery_images = get_field('add_images'); ?>
<img src="<?php echo $gallery_images[0]['sizes']['thumb']; ?>" alt="image of <?php the_title(); ?>" />


The code below comes from previous next plugin.
if ( $r['thumb'] && has_post_thumbnail($post->ID) ) {
if ( $r['thumb'] === true ) // use 'post-thumbnail' as the default size
$r['thumb'] = 'post-thumbnail';
$thumbnail = '<a class="post-thumbnail" href="'.get_permalink($post).'" rel="'.$rel.'"'.$tooltip.'>' . get_the_post_thumbnail( $post->ID, $r['thumb'] ) . '</a>';
$format = $thumbnail . '<span class="post-link">' . $format . '</span>';
}



I want to use the first block of code and replace the post thumbnail with my thumbnail above.

screenshot below

Answers (4)

2014-04-19

zebra webdesigns answers:

Hello Rick , did you modified the code already, or is the code provided comes from previous next plugin.
also can you give the exact plugin link.
If this is urgent you can contact me through skype
My skype ID bhuvan530531


Rick Bible comments:

Did not modify the code,
http://wordpress.org/plugins/ambrosite-nextprevious-post-link-plus/


zebra webdesigns comments:

Ok I will take a look at it and you are using a plugin which hasnt been updated for long time.
I will get back to you


Rick Bible comments:

yeh, I know its old but seems solid


zebra webdesigns comments:

Hello Rick here is the exact code

if ( $r['thumb'] && has_post_thumbnail($post->ID) ) {
if ( $r['thumb'] === true ) // use 'post-thumbnail' as the default size
$r['thumb'] = 'post-thumbnail';
$meta_values = get_post_meta( $post->ID, 'add_images' );
$image_output=wp_get_attachment_image_src( $meta_values[0]);
$thumbnail = '<a class="post-thumbnail" href="'.get_permalink($post).'" rel="'.$rel.'"'.$tooltip.'><img src="' .$image_output[0]. '"/></a>';
$format = $thumbnail . '<span class="post-link">' . $format . '</span>';
}


This will output the thumbnail of the image


zebra webdesigns comments:

Please find the attached image as how the final output comes