Title: Can functionality be inverted?
Last modified: August 22, 2016

---

# Can functionality be inverted?

 *  Resolved [morgentau](https://wordpress.org/support/users/morgentau/)
 * (@morgentau)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/can-functionality-be-inverted/)
 * Hi,
 * I’ve found your plugin through the WordPress forums and I’d first like to say
   thank you for sharing it with the community. I’ve been looking for precisely 
   this functionality and your plugin is fast and very easy to use.
 * I’m using it in the template only, no shortcodes or widgets, using “km_rpbt_related_posts_by_taxonomy”(
   which BTW isn’t clearly mentioned in the main page of the documentation).
 * I was wondering if there was an option to reverse the output of the function,
   i.e. make it returns posts which have the fewest (or no) common tags with the
   current post.
 * Thank you very much.
 * [https://wordpress.org/plugins/related-posts-by-taxonomy/](https://wordpress.org/plugins/related-posts-by-taxonomy/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/can-functionality-be-inverted/#post-5925949)
 * Hi morgentau.
 * The related posts should have at least one term in common. Otherwise what is 
   the point of the plugin 🙂
 * Have you tried with `'order' => 'ASC'`.
 * The only thing you can do without editing plugin files is to get all the related
   posts and use the php function array_reverse().
    [http://php.net/manual/en/function.array-reverse.php](http://php.net/manual/en/function.array-reverse.php)
 * Here is an example.
 *     ```
       <?php
   
       // check if the function exists
       if ( function_exists( 'km_rpbt_related_posts_by_taxonomy' ) ) {
   
       	$args = array(
       		'posts_per_page' => -1,
       	);
   
       	$taxonomies = array( 'category', 'post_tag' );
   
       	// get the related posts
       	$related_posts = km_rpbt_related_posts_by_taxonomy( $post->ID, $taxonomies, $args );
   
       	// reverse the related posts
       	$related_posts = array_reverse( $related_posts );
   
       	// use first 5 related posts
       	$related_posts = array_slice( $related_posts, 0, 5 );
   
       	if ( $related_posts ) {
   
       		echo '<h2>Related Posts</h2>';
       		echo '<ul>';
   
       		// Loop through the related posts.
       		foreach ( (array) $related_posts as $related ) {
   
       			echo '<li><a href="' . get_permalink( $related->ID ) . '">' . $related->post_title . '</a></li>';
       		}
   
       		echo '</ul>';
       	}
       }
       ?>
       ```
   
 *  Thread Starter [morgentau](https://wordpress.org/support/users/morgentau/)
 * (@morgentau)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/can-functionality-be-inverted/#post-5926005)
 * OK, thank you very much for this example.
 * In a future update maybe? This plugin is extremely useful.
 * Cheers.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Can functionality be inverted?’ is closed to new replies.

 * ![](https://ps.w.org/related-posts-by-taxonomy/assets/icon.svg?rev=1115231)
 * [Related Posts by Taxonomy](https://wordpress.org/plugins/related-posts-by-taxonomy/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/related-posts-by-taxonomy/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/related-posts-by-taxonomy/)
 * [Active Topics](https://wordpress.org/support/plugin/related-posts-by-taxonomy/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/related-posts-by-taxonomy/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/related-posts-by-taxonomy/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [morgentau](https://wordpress.org/support/users/morgentau/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/can-functionality-be-inverted/#post-5926005)
 * Status: resolved