1. <?php
  2. $scores = the_related_get_scores(); // pass the post ID if outside of the loop
  3. $posts = array_slice( array_keys( $scores ), 0, 5 ); // keep only the the five best results
  4. $args = array(
  5. 'post__in' => $posts,
  6. 'posts_per_page' => 5,
  7. 'caller_get_posts' => 1 // ignore sticky status
  8. );
  9. $my_query = new WP_Query( $args );
  10. if ( $my_query->have_posts() ) {
  11. while ( $my_query->have_posts() ) {
  12. $my_query->the_post();
  13. echo '<a href="' . get_permalink( get_the_ID() ) . '">';
  14. the_title();
  15. echo '</a>';
  16. the_excerpt();
  17. if ( has_post_thumbnail() ) {
  18. the_post_thumbnail( 'thumb' );
  19. }
  20. echo '<br>';
  21. }
  22. }
  23. else {
  24. echo "No posts found...";
  25. }
  26. ?>