Related Posts by Taxonomy


Quickly increase your readers‘ engagement by adding related posts in the sidebar or after post content with a widget or shortcode.

Posts with the most terms in common will display at the top!

This plugin is capable of finding related posts in multiple taxonomies and post types. Include or exclude terms from the search for related posts. Change the look and feel by using your own templates in a (child) theme.

plugin documentation

Plugin features:

  • Widget and Shortcode.
  • Display related posts as post thumbnails, links, excerpts or full posts.
  • Small Footprint. Doesn’t slow down your site!
  • Automatic display of related posts after the post content.
  • Exclude or include terms and posts.
  • Search for related posts in single or multiple taxonomies and post types.
  • Limit the search for related posts by date, number or post meta.
  • Use your own HTML templates for display of the related posts.
  • Extensive plugin documentation.
  • Follows WordPress coding standards and plugin best practices.
  • Highly Adjustable!

For the following features you need to be somewhat familiar with WordPress hooks. The plugin documentation has many examples to help you along.

Extended features:

  • The WordPress object cache is used for the related posts query.
  • Use the plugin persistent cache for the related posts query. (opt-in feature)
  • Use the WordPress REST API to get related posts. (opt-in feature)
  • Load related posts after the whole page has loaded (with Ajax). (opt-in feature)
  • Use plugin functions in your theme templates to display related posts yourself.
  • Use Filters to change the default behavior of the plugin.

Follow this plugin on GitHub.
Search the code reference

See the FAQ to have related posts automatically display after the post content without using the shortcode or widget.

Default usage for the shortcode is:


Attributes for the shortcode are:

  • post_id
  • taxonomies
  • post_types
  • posts_per_page
  • order
  • orderby
  • before_shortcode
  • after_shortcode
  • title
  • show_date
  • before_title
  • after_title
  • terms
  • include_terms
  • include_parents
  • include_children
  • exclude_terms
  • exclude_posts
  • format
  • gallery_format
  • image_size
  • columns
  • caption
  • link_caption
  • limit_posts
  • limit_month
  • meta_key
  • meta_value
  • meta_compare
  • meta_type
  • related
  • public_only
  • include_self
  • post_class

Example to show 10 related posts instead of the default 5.

[related_posts_by_tax posts_per_page="10"]

See the documentation for more information about these attributes.



  • The Widget
  • Twenty Fifteen screenshot. Related posts in the sidebar and after post content
  • Twenty Twelve screenshot. Post thumbnails (after post content) and the widget
  • Twenty Thirteen screenshot. Post thumbnails (after post content) and the widget


  • Unzip the folder.
  • Upload the related-posts-by-taxonomy folder to your /wp-content/plugins directory.
  • Activate Related Posts by Taxonomy.
  • That’s it, now you are ready to use the widget and shortcode


For more information about the plugin see the plugin documentation.
To customize this plugin see the plugin recipes page.

Can I change the layout for the related posts?

Yes. Review this section of the documentation to style the related posts yourself.

How can I automatically add related posts after the post content?

Review Adding Related Posts After the Post Content.

Can I include or exclude posts or terms with the widget or shortcode

Yes. For the widget see this filter and for the shortcode see the attributes terms, include_terms, exclude-terms and exclude_posts.

Can I set my own defaults for the shortcode?

Yes. Review Setting your own defaults for the shortcode

The widget only lets you choose „all taxonomies“ or a single taxonomy. Can I make it use multiple specific taxonomies?

Yes. See this filter on how to do that.

Is this plugin GDPR compliant?
  • This plugin doesn’t process, share, send or retain any user data.
  • This plugin doesn’t track (user) data for analytics (or for any other reason).
  • This plugin doesn’t save or read cookies.
  • This plugin doesn’t use 3rd party libraries.

Read this article why plugin authors cannot guarantee 100% compliance.

Please contact a GDPR consultant or law firm with this information to assess if this plugin is compliant.


Works good, light, secure

Many thanks for the plugin, I use it on many sites. Really good work. PS I need to open related links in a new window, submitted my topic in support forums

Very nice work

I really love this plugin. I was thinking if you guys could please include time options such that I can choose to show my latest posts and exclude old posts. Thank you.

Fantastically coded and well supported

On my bespoke site, I wanted to sort out 'related' posts for a specific post type. I was dreading the mess of comparing taxonomies and even considering which ones I should 'weigh' more than others. Plus I wanted to factor in some other fun mathematical aspects based on previously calculated values. I'd (cleverly, I thought) done the up front work of multiple custom taxonomies, where related posts could be found. And yes, I had the use of a faceted filtering engine to help people find things. But I wanted more. I wanted to be able to say "Did you like this show? Here are some more!" My goal was to get the code done pre WCUS, and I had just started to break out the work into manageable chunks over US thanksgiving, with the code beginning to take shape, when I thought "Surely someone has done this..." At first, all I found were plugins that did one job or another. One related your defined meta values, one let you manually chose, and so on. Then I found this one and struck the motherlode. Gold, I tell you, pure gold! Sure while it looked like just 'another' related taxonomy plugin. Then I read the documentation and was rhapsodic! @keesiemeijer put in the work to make it filterable and hookable! I could take that expert work and add on to it, using the basic related posts by taxonomies and add in my weird meta values. When I stumbled, I asked for help and found it with a brand new filter made just for insane people like me. Out of the box, this plugin works amazingly well. Fast, lightweight, and efficient. Add in those filters? It's the best thing since Betty White.
Lies alle 67 Rezensionen

Mitwirkende & Entwickler

„Related Posts by Taxonomy“ ist Open-Source-Software. Folgende Menschen haben an diesem Plugin mitgewirkt:


„Related Posts by Taxonomy“ wurde in 5 Sprachen übersetzt. Danke an die Übersetzerinnen und Übersetzer für ihre Mitwirkung.

Übersetze „Related Posts by Taxonomy“ in deine Sprache.

Interessiert an der Entwicklung?

Durchstöbere den Code, sieh dir das SVN Repository an oder abonniere das Entwicklungsprotokoll per RSS.



  • Enhancement
    • New format for related galleries similar to the Gutenberg gallery block.
    • Include child or parent terms for the related posts query.
    • Filters for Widget defaults and instance.
  • Bug Fixes
    • (minor) Don’t default to all public taxonomies if no valid taxonomies are used.


  • Enhancement
    • Meta query
      • Allows you to query related posts with post meta
      • Use meta arguments in the shortcode
      • Use a filter for the widget or for complex meta queries
    • ID query
      • Allow queries for post IDs only. (for the related posts in the widget and shortcode templates)
      • Speeds up the related posts query. (not activated by default because of back compatibility)
      • Please read the documentation about query optimization before using this feature
    • Lazy loading (opt in feature).
      • Speeds up perceived page load time for very large sites
      • Does the query for related posts (with Ajax) after the page is loaded
      • Recommended for related posts below the fold.
    • Detect post type Page taxonomies
    • Preparing the plugin for the (Gutenberg) editor block feature


  • Enhancement
    • Add ability to show the post date after the post title
    • Allow getting post fields from the cache
    • Add new filter to filter all related post permalinks
    • Add new tests for the post type feature (GitHub)
  • Bug fixes
    • (minor) Add post classes after retrieving posts from the cache
    • (minor) Return an error if invalid taxonomies or post types was requested with the WP Rest API


  • Enhancement
    • Prepare plugin for gutenberg blocks
    • Add ‚terms‘ parameter for shortcode and widget
    • Add GDPR information to readme.txt
    • deprecate functions (with back compatibility)
      • km_rpbt_related_posts_by_taxonomy()
      • km_rpbt_get_default_args()
      • km_rpbt_related_posts_by_taxonomy_validate_ids()
      • km_rpbt_related_posts_by_taxonomy_template()
      • km_rpbt_post_title_link()
      • km_rpbt_get_related_post_title_link()
      • km_rpbt_related_posts_by_taxonomy_widget()
  • Bug fixes
    • (minor) Add missing filter pre_related_posts before cache queries
    • (minor) Add missing properties to related posts returned by the cache


  • Enhancement
    • Add post classes with filters or as a shortcode or widget argument
    • Move included current post to the top of the stack by default


  • Enhancement
    • Add public_only parameter to not display private related posts from the current author.
    • Add include_self parameter to include the current post in the related posts.
    • Add filter pre_related_posts to override the related posts query.
  • Bug fixes
    • Fix duplicate gallery IDs breaking the column layout of WordPress galleries. Props: @sonamel

For older changelog versions see the changelog.txt file