Limit tag word count

Use the pre_insert_term filter:

function wpse_189722_limit_tag_words( $term, $taxonomy ) {
    if ( $taxonomy === 'post_tag' ) {
        if ( count( preg_split( '/\s+/', trim( $term ) ) ) > 2 )
            $term = new WP_Error( 'term_too_many_words', 'Maximum of 2 words' );
    }

    return $term;
}

add_filter( 'pre_insert_term', 'wpse_189722_limit_tag_words', 10, 2 );

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)