[post_terms]

The shortcode is designed to display the terms.


Product


Shortcode Attributes

  1. id – Post ID for which the terms should be displayed.
    • Options: Any valid post ID.
  2. taxonomy: The taxonomy from which to retrieve terms.
    • Default: category.
    • Options: category, post_tag, or custom taxonomy.
  3. disable_html – Specifies the target attribute for the link.
    • Default: 0.
    • Options: 0 or 1. Specify one only.
  4. separator – The separator used between terms when disable_html is enabled.
    • Default: , .
    • Options: Any text value.
  5. classes – Specifies additional CSS classes for styling the link.
  6. label – A label above the list of terms.
    • Options: Any text value.

Shortcode Enclosed Content

Any content placed between [post_terms] and [/post_terms] will be used as a template, where {content} acts as a placeholder for the post terms.


Example Usage

Example 1

[post_terms]

Results

<div class="terms" data-taxonomy="category">
    <a href="http://example.com/category/term-1">Term 1</a>
    <span class="hic-seperator"></span>
    <a href="http://example.com/category/term-2">Term 2</a>
</div>
This example will display the categories for the current post, with each category linked to its archive page.
Dynamic Post ID: If the id parameter is not provided, the shortcode will automatically use the current post ID. If the post type is location_post or location_page, it will retrieve the ID from a custom field (link_to_location).

Example 2

[post_terms id="123" taxonomy="post_tag"]

Results

This example will display the tags for the post with ID 123, with each tag linked to its archive page

Example 3

[post_terms disable_html="1" separator=" | "]

Results

This example will display the terms as plain text, separated by | :
Term 1 | Term 2
Line Breaks: If the separator is set to \n, the terms will be displayed on separate lines using wpautop.

Example 4

[post_terms label="Categories: " class="post-terms-list"]

Results

<label>Categories: </label>
<div class="terms post-terms-list" data-taxonomy="category">
    <a href="http://example.com/category/term-1">Term 1</a>
    <span class="hic-seperator"></span>
    <a href="http://example.com/category/term-2">Term 2</a>
</div>
This example will display the terms with a label Categories: and apply the CSS class post-terms-list to the container

Example 5

[post_terms]<div class="custom-wrapper">{content}</div>[/post_terms]

Results

<div class="custom-wrapper">
    <div class="terms" data-taxonomy="category">
        <a href="http://example.com/category/term-1">Term 1</a>
        <span class="hic-seperator"></span>
        <a href="http://example.com/category/term-2">Term 2</a>
    </div>
</div>
This shortcode generates a <div> element with the class custom-wrapper, containing the list of terms.