WordPress.org

Ready to get started?Download WordPress

Forums

Better Related Posts
Related content thumbnails in custom post type? (1 post)

  1. gothbarbie
    Member
    Posted 1 year ago #

    Hello!

    I tried the loop you posted (below), but I would like to edit it to show my custom post-type, "videos". If anyone can help me out with the syntax for that, I would be very thankful..!

    <?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' );
    }
    								        }
    								    }
    								    else {
    echo "No related videos found...";
    }
    ?>

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic