Special New Year Sale

Save 23% on TaxoPress with this coupon:

NewYear2023

Buy Now
TaxoPress
reorder
  • Features
  • Docs
  • Blog
  • Support
  • Login
  • Get TaxoPress Pro

TaxoPress: Getting Started

  • How to Install TaxoPress
  • Technical Requirements for TaxoPress
  • How to Activate or Deactivate TaxoPress Features
  • How to Move from TaxoPress Free to Pro
  • TaxoPress Free vs Pro
  • Characters and Alphabets Supported by TaxoPress

TaxoPress: Taxonomies

  • Introduction to the Taxonomies Screen
  • Taxonomies: Post Types
  • Taxonomies: Permalinks
  • Taxonomies: Admin Area
  • Taxonomies: Other Labels
  • Taxonomies: REST API
  • Taxonomies: Advanced
  • Taxonomies: Deactivate or Delete
  • Media Tags

TaxoPress: Terms

  • Introduction to the Terms Screen

TaxoPress: Terms Display

  • Introduction to Terms Display
  • Show the Terms Display with a Shortcode
  • Show the Terms Display in a Widget
  • Change the Format of Terms Display
  • Add CSS to Your Terms Display
  • Show Terms Display Using PHP

TaxoPress: Current Post

  • Introduction to Terms for Current Post
  • Automatically Display Terms for Current Post
  • Options for Terms for Current Post
  • Change the Format of Terms for Current Post
  • Add CSS to Terms for Current Post
  • Show Current Post Terms With PHP

TaxoPress: Related Posts

  • Introduction to Related Posts
  • Where to Display Related Posts
  • Options for Related Posts
  • Change the Format of Related Posts
  • Add CSS to Your Related Posts
  • Show Related Posts Using PHP

TaxoPress: Auto Links

  • Introduction to Auto Links
  • Auto Links Options

TaxoPress: Auto Terms

  • The Auto Terms Feature on Large Sites
  • Introduction to Auto Terms
  • Auto Terms Options
  • Sources for Auto Terms
  • Automatically Add New Terms
  • Automatically Add Existing Terms
  • Add Auto Terms to Existing Content
  • How to Schedule the Auto Terms Feature
  • Logs for Auto Terms
  • Use Regular Expressions to Analyze Content

TaxoPress: Suggest Terms

  • Introduction to Suggest Terms
  • Using the Dandelion API for Suggest Terms
  • Using the OpenCalais API for Suggest Terms

TaxoPress: Mass Edit Terms

  • Introduction to Mass Edit Terms

TaxoPress: Manage Terms

  • Introduction to Manage Terms
  • Add Terms
  • Merge Terms
  • Remove Terms
  • Rename Terms
  • Delete Terms
  • Delete Unused Terms

TaxoPress: Security

  • Automated Security Checks, including Checkmarx
  • Security Issues and How to Report Them
  • Capabilities / Permissions in TaxoPress

TaxoPress Pro

  • TaxoPress Free vs Pro
  • How to Move from TaxoPress Free to Pro
  • TaxoPress License Keys and Multisite Networks
  • TaxoPress Pro License Keys and Local Environments
  • TaxoPress Pro Refund Policy

TaxoPress: Integrations

  • Working with the Dandelion API
  • How to Register for the Dandelion API Service
  • How to Register for OpenCalais
  • Functions for Theme Integration

TaxoPress: Troubleshooting

  • The Auto Terms Feature on Large Sites
  • What Happened to the Click Tags Feature?
  • Troubleshooting TaxoPress Screens
  • Home
  • TaxoPress Documentation
  • TaxoPress
  • TaxoPress: Related Posts
  • Show Related Posts Using PHP

Show Related Posts Using PHP

It is possible to add the “Related Posts” output directly into your site’s PHP files.

The best approach is to use the PHP to include the shortcode inside a PHP snippet, as in this example below.

<?php echo do_shortcode("[taxopress_relatedposts id="1"]"); ?>

Legacy PHP Code

There is also a legacy option allows you to make choices directly in the PHP code. This is the basic code snippet:

<?php st_related_posts(); ?>

Here are examples of how you can customize that basic code with more details:

'number' => 5,
'order' => 'count-desc',
'format' => 'list',
'include_page' => 'true',
'exclude_posts' => '',
'exclude_tags' => '',
'post_id' => '',
'except_wrap' => '55',
'limit_days' => '0',
'title' => __('<h4>Related posts</h4>', 'simpletags'),
'nopoststext' => __('No related posts.', 'simpletags'),
'dateformat' => $this->dateformat,
'xformat' => __('<a href="%post_permalink%" title="%post_title% (%post_date%)">%post_title%</a> (%post_comment%)', 'simpletags')

Here is an example of that legacy code in use. We want to show the first 10 related post without title, without pages and without comments count.

<?php st_related_posts('number=10&title=&include_page=false&xformat=<a href="%permalink%" title="%title% (%date%)">%title%</a>'); ?>

Here are all the legacy code parameters:

  • number
    • (integer) Number of posts to show
  • order
    • (string) Order posts sorting. Valid values are :
      • count-desc – (default) by number of common tags (most relevance)
      • count-asc – by number of common tags (less relevance)
      • date-desc – by publication’s date descending
      • date-asc – by publication’s date ascending
      • name-asc – by title ascending
      • name-desc – by title descending
      • random – random
  • format
    • (string) show tags as non ordered list UL/LI
      • flat – (Default) posts are separated with spaces
      • list – posts are inside non ordered lists containing class=’related_posts’
      • array -posts are inside a PHP array (use it with st_get_related_posts())
  • include_page
    • (boolean) “true” to add pages, “false” only for posts
  • exclude_posts
    • (string) Separate posts ID to exclude with commas
  • exclude_tags
    • (string) Separate tags ID to exclude with commas
  • post_id
    • (integer) Specified post ID for display related posts
  • except_wrap
    • (integer) Words number for excerpt.
  • limit_days
    • (string) Limit result with a max days
  • title
    • (string) Specify the positioned title before the list
  • nopoststext
    • (string) Specify the text to show when there is no related post
  • dateformat
    • (string) Specify the date format. Same format as PHP date function
  • xformat
    • (string) Extended links format. Available Markups :
      • post_date – Replaced by the date of the post
      • post_permalink – Replaced by the permalink of the link
      • post_title – Replaced by the title of the post
      • post_comment – Replaced by the comments count of the post
      • post_tagcount – Replaced by the number of common tags
      • post_id – Replaced by the ID of the post
      • post_relatedtags – Replaced by common tag list
      • post_excerpt – Replaced by post excerpt
Tags: Related Posts

Recent Posts

  • How to Show WordPress Posts With a Specific Taxonomy Term November 11, 2022
  • How to Use the Site Editor to Design WordPress Taxonomy Archives November 9, 2022
  • What Characters Are Allowed in WordPress Taxonomy Terms? October 26, 2022
  • The Tag Groups Plugin is Now Part of TaxoPress October 14, 2022
  • How to Merge Similar Taxonomy Terms in WordPress September 14, 2022

Testimonials

It is awesome to finally have tags organized. Thank you so much for this simple but powerful plugin!

kenethrd

This plugin is the best available for suggesting tags, is also easy to install and use. Highly recommended.

supertrooper2

Search TaxoPress.com

Important Links

  • Frequently Asked Questions
  • About the TaxoPress Team
  • Terms of Service
  • TaxoPress Affiliates
  • Logo and Brand Materials

Our Projects

  • PublishPress
  • MetaSlider
  • KinshiPress
  • Ramble Ventures
  • Logtivity