WordPress.org

Support

Support » Plugins and Hacks » Related content thumbnails in custom post type?

Related content thumbnails in custom post type?

  • gothbarbie
    Member

    @gothbarbie

    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/

  • The topic ‘Related content thumbnails in custom post type?’ is closed to new replies.