The genesis post categories shortcode prints all the categories you have assigned to each post in the entry footer on single posts and archives. The function for this is located in genesis > lib > shortcodes > post.php.
add_shortcode( 'post_categories', 'genesis_post_categories_shortcode' );
function genesis_post_categories_shortcode( $atts ) {
<pre><code>$defaults = array(
'sep' => ', ',
'before' => __( 'Filed Under: ', 'genesis' ),
'after' => '',
);
$atts = shortcode_atts( $defaults, $atts, 'post_categories' );
$cats = get_the_category_list( trim( $atts['sep'] ) . ' ' );
//* Do nothing if no cats
if ( ! $cats ) {
return '';
}
if ( genesis_html5() )
$output = sprintf( '<span %s>', genesis_attr( 'entry-categories' ) ) . $atts['before'] . $cats . $atts['after'] . '</span>';
else
$output = '<span class="categories">' . $atts['before'] . $cats . $atts['after'] . '</span>';
return apply_filters( 'genesis_post_categories_shortcode', $output, $atts );
</code></pre>
}
The function for the shortcode uses get_the_category_list
which is located in wordpress > wp-includes > category-template.php.
function get_the_category_list( $separator = '', $parents='', $post_id = false ) {
Demo Video
Here’s a demonstration showing you how the code removes 2 category links from the entry meta in the entry footer of the Genesis Sample child theme by StudioPress:
Here’s the code for logged in members:
You can also use the code in this download folder to exclude categories by category ID.
Hello,
In the second option, how can I exclude multiple categories?
Thanks,
Marcelo
Why can’t you use the first function for this?
Try this code using category ID’s https://wpsites.net/download/97139
Hello,
Thank you very much for your super fast answer. This code is great, it is very simple and clean, and it does exactly what I want. It is a very elegant solution, love it!
Thank you 🙂
Marcelo