Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1229754

    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.

    #1229758

    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!

    #1229913

    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

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Display Count of portfolio items in a certain portfolio Category’ is closed to new replies.