Besides hooks, Genesis Framework has lots of shortcodes to help you customize your child theme. Before this, we’ve published a tutorial on creating your first custom post type and custom taxonomy and today, we’ll show how easy it is to display the custom taxonomy on your site.
Filed Under: Snippets Shortcode
If you refer to Genesis shortcode reference page, you’ll notice a less-known
Filed Under: Snippetsshortcode. To display any custom taxonomy, we’ll be using this shortcode and place it on entry meta. The shortcode accepts 4 parameters:
sep – This will be the separator for the post terms list. The default is comma.
before – Text to be displayed before the post terms list. The default is “Filed Under: “, same as a category.
after – Text to be displayed after the post terms list.
taxonomy – Specify which taxonomy to be displayed. This is the most important parameter need to be specified. The default value is category.
Displaying Custom Taxonomy in Entry Meta (Footer)
To display the custom taxonomy in entry meta (footer), we’ll use
genesis_post_metafilter. Here’s a working code that can be placed on your child theme
In this example, ‘Type’ is my custom taxonomy. Please note that the code above will overwrite the current entry meta and therefore it will remove post categories and tags.
Conditionally Display Custom Taxonomy on Custom Post Type
To conditionally display custom taxonomy anywhere on your site, we need to use conditional tags. In this example, we are using
is_post_type_archive tags. Here’s a tested and working code that can be placed on your child theme function.php file:
What the code will do is basically to only display the custom taxonomy on single page of Portfolio post type and on the archive page of Portfolio post type.
Genesis Feature Post Widget
The best thing about Genesis shortcodes is they can also be used on Genesis Featured Post widget. Therefore, if you’ve custom taxonomy and would like to display it, you may also use the
Filed Under: Snippets shortcode.
Simply replace “type” and “Type: ” with the name of your custom taxonomy.
We hope this tutorial helped you to easily display the custom taxonomy on your theme. For more info about Gensis Framework shortcode, I highly suggest you check out the Shortcode Reference page on StudioPress site.