Display Posts can include a list of terms associated with each post in the listing. These can be categories, tags, or any custom taxonomy.
If you set category_display="true"
it will include a listing of the categories. You can also list tags ( category_display="post_tag"
) or any custom taxonomy ( category_display="taxonomy_name"
).
Here’s an example from this site. I use a taxonomy called “dps_filter” to categorize tutorials based on what filter they use.
Shortcode
[display-posts category_display="dps_filter" category_label="Filters used: "]
Result
- Display posts as a select dropdown Filters used: display_posts_shortcode_output, display_posts_shortcode_wrapper_close, display_posts_shortcode_wrapper_open
- Remove “by” when displaying author name
- Display specific posts
- Reversed Ordered List Filters used: display_posts_shortcode_wrapper_open
- Display image from post content if no featured image Filters used: display_posts_shortcode_output
- Add extra text after title Filters used: pre_display_posts_shortcode_output
- Use the WordPress date format Filters used: shortcode_atts_display-posts
- Add Post ID class to each listing item
- Add class to current post for styling Filters used: display_posts_shortcode_post_class
- Display post count as title of listing Filters used: do_shortcode_tag, shortcode_atts_display-posts
Removing category links
If you don’t want the category names to be clickable to their archive pages, use the following code:
This code snippet goes in a core functionality plugin or Code Snippets.
// Remove category links
add_filter( 'display_posts_shortcode_category_display', 'strip_tags' );
Filters used:
display_posts_shortcode_category_display