How to build an image related post plugin
-
Hi all,
I use the WP 2.3 Related Posts plugin (https://fairyfish.net/2007/09/12/wordpress-23-related-posts-plugin/) in order to display the related post under a post. What I want to do is to display a thumbnail from the related post near its link like in https://www.lifehacker.com/.
I want to use this piece of code to display the attachment thumb but it doesn’t work…
<a href="<?php echo wp_get_attachment_url($post->ID); ?>"><?php echo wp_get_attachment_image( $post->ID, 'thumb' ); ?></a>
I think I must input it in this code (wp 2.3 related posts code) :
foreach ($related_posts as $related_post ){ $output .= '<li>'; $show_date = get_option("wp23_RP_Date"); if ($show_date){ $dateformat = get_option('date_format'); $output .= mysql2date($dateformat, $related_post->post_date) . " -- "; } $output .= '<a href="'.get_permalink($related_post->ID).'" title="'.wptexturize($related_post->post_title).'">'.wptexturize($related_post->post_title).''; $show_comments_count = get_option("wp23_RP_Comments"); if ($show_comments_count){ $output .= " (" . $related_post->comment_count . ")"; } $output .= '</a></li>'; } $output = '<h3>'.$wp23_RP_title .'</h3>'.'<ul class="related_post">' . $output . '</ul>'; return $output;
If anyone can help me… Thanks
Viewing 15 replies - 1 through 15 (of 15 total)
Viewing 15 replies - 1 through 15 (of 15 total)
- The topic ‘How to build an image related post plugin’ is closed to new replies.