WordPress.org

Ready to get started?Download WordPress

Forums

Better Related Posts
Better Related Posts - Thumbnails 0.4.3.3 (1 post)

  1. mistercyril
    Member
    Posted 3 years ago #

    Hello,

    I am a bit confused as to how thumbnails can be added to the related posts.

    I tried this but it doesn't work with custom posts:

    <?php
    	$scores = the_related_get_scores(); // pass the post ID if outside of the loop
    	$posts = array_slice( array_keys( $scores ), 0, 5 ); // keep only the the five best results
    	$args = array(
    	    'post__in'			=> $posts,
    		'posts_per_page'	=> 5,
    		'caller_get_posts'	=> 1 // ignore sticky status
    	);
    	$my_query = new WP_Query( $args );
    	if ( $my_query->have_posts() ) {
    	    while ( $my_query->have_posts() ) {
    	        $my_query->the_post();
    	        echo '<a href="' .  get_permalink( get_the_ID() ) . '">';
    	        the_title();
    	        echo '</a>';
    	        the_excerpt();
    	        if ( has_post_thumbnail() ) {
    	            the_post_thumbnail( 'thumb' );
    	        }
    	        echo '<br>';
    	    }
    	}
    	else {
    	    echo "No posts found...";
    	}
    ?>

    http://wordpress.org/extend/plugins/better-related/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic