Hi!
Is there a way to display the count of portfolio items in a certain portfolio category using shortcode?
I added the code below in function.php file but i just learned that it can only count post categories and not the portfolio (custom type).
function category_post_count( $atts ) {
$atts = shortcode_atts( array(
‘category’ => null
), $atts );
$term = get_term_by( ‘slug’, $atts[‘category’], ‘category’);
return ( isset( $term->count ) ) ? $term->count : 0;
}
add_shortcode( ‘category_post_count’, ‘category_post_count’ );
Thank you in advance.
Hi again!
Please close this now. I have figured it out. I need to change this line below.
$term = get_term_by( ‘slug’, $atts[‘category’], ‘category’)
to this
$term = get_term_by( ‘slug’, $atts[‘category’], ‘portfolio_entries’);
Thanks!
Hi melaniecuando,
We’re glad to hear that :)
And thanks for showing the solution that worked for you.
Thanks again for using Enfold and have a great day!
Best regards,
Nikko