12% off of LTD using this coupon: TWELVEPERCENTOFF. Promo ends on 2 Dec midnight UTC.
Published on Nov 4, 2020

[Shortcode] Linked Taxonomy Terms with Exclude option

Sridhar Katakam

Updated on December 17, 2020

This members-only tutorial is similar to [Shortcode] Unlinked Taxonomy Terms with the following differences:

  1. The terms will be linked to corresponding term archive pages.
  2. There is an additional exclude parameter for the shortcode using which one or more term IDs can be excluded.

The shortcode shared here allows you to display comma-separated linked terms of the specified taxonomy (can be standard ones or a custom taxonomy) when viewing single pages of a post or any other Custom Post Type.

Ex.:

[post_terms_linked taxonomy="portfolio_category" exclude="32,212" before="Categorized under: "]

Let's say a portfolio Custom Post Type item has been these portfolio_categorys: Branding and Featured.

Assuming a scenario where you have selected the "Featured" portfolio category for the purposes of making this CPT entry appear inside a slider on the homepage you would typically not want "Featured" to appear in this post's terms list.

Output of [post_terms_linked taxonomy="portfolio_category"]:

Output of [post_terms_linked taxonomy="portfolio_category" exclude="45"] where 45 is the ID of "Featured" term:

The available shortcode parameters (all optional) are:

  • taxonomy: name of a taxonomy. Default: category
  • exclude: Comma-separated IDs of post terms to be excluded. Do NOT put space after commas. Default: ''
  • sep: String that should separate each term link. Default: , (a comma followed by a space)
  • before: String to appear before the terms. Default: Filed Under:
  • after: String to appear after the terms. Default: ''

Step 1

Install and activate Code Snippets plugin.

Go to Snippets > Add New.

Title: [Shortcode] Linked Taxonomy Terms

Code:

This is a premium members-only content.

To view the rest of the content, please sign up for membership ($47/month or $599 one-time).

Already a member? Log in below or here.

tagschevron-leftchevron-rightchainangle-rightangle-upangle-downfolder-omagnifiercrossmenuchevron-downarrow-right