Limit categories in post meta

Community Forums Forums General Discussion Limit categories in post meta

This topic is: not resolved

This topic contains 1 reply, has 2 voices, and was last updated by  Peter 1 year, 6 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #18680

    reckoner41
    Participant
    Post count: 3

    Is there a way to customize the post meta so that if a post is in 10 categories the post meta will only display the first 3?

    #21124

    Peter
    Participant
    Post count: 76

    You could use something like this to limit the number of categories displayed;

    [php]add_filter( ‘get_the_categories’, ‘limit_get_the_categories’ );
    function limit_get_the_categories( $cats ) {
    return array_slice( $cats, 0, 3 );
    }[/php]


    Website: petercoughlin.com
    Twitter: petercoughlin

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.