Support » Developing with WordPress » Limit custom post type title word length

  • Resolved Pete

    (@perthmetro)


    I have this function that limits the titles of posts and pages to 10 words. How would this function be edited to allow only a specific custom post type to have it’s title word length limited?

    add_filter( 'the_title', 'wpse_75691_trim_words' );
    
    function wpse_75691_trim_words( $title )
    {
        // limit to ten words
        return wp_trim_words( $title, 10, '' );
    }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Limit custom post type title word length’ is closed to new replies.