Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $scores = the_related_get_scores(get_the_ID(), array(
- 'usept' => array(
- 'post' => true
- ),
- 'usetax' => array(
- 'post_tag' => true
- ),
- ));
- $posts = array_slice(array_keys( $scores ), 0, 5 ); // keep only the the five best results
- $args = array(
- 'suppress_filters' => true, // necessary in combination with the sticky-custom-post-types plugin
- 'post__in' => $posts,
- 'posts_per_page' => 5,
- 'caller_get_posts' => 1,
- );
- $my_query = new WP_Query( $args );
- function orderby( $a, $b ) {
- global $posts;
- $apos = array_search( $a->ID, $posts );
- $bpos = array_search( $b->ID, $posts );
- return ( $apos < $bpos ) ? -1 : 1;
- }
- usort( $my_query->posts, "orderby" );
- if ( $my_query->have_posts()) { ?>
- <ul class="posts">
- <?php while ( $my_query->have_posts()) : $my_query->the_post(); ?>
- <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?> - <span class="list-date"><?php echo get_the_date(); ?></span></a></li>
- <?php endwhile; ?>
- <?php wp_reset_query(); ?>
- </ul>
- <?php } else { ?>
- <p>No related features found</p>
- <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement