[post_terms]
The shortcode is designed to display the terms.
Product
Shortcode Attributes
- id – Post ID for which the terms should be displayed.
- Options: Any valid post ID.
- taxonomy: The taxonomy from which to retrieve terms.
- Default:
category. - Options:
category,post_tag, or custom taxonomy.
- Default:
- disable_html – Specifies the target attribute for the link.
- Default:
0. - Options:
0or1. Specify one only.
- Default:
- separator – The separator used between terms when
disable_htmlis enabled.- Default:
., - Options: Any text value.
- Default:
- classes – Specifies additional CSS classes for styling the link.
- 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. |
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 |
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. |