Limiting number of TAGS in TAGS text field when asking a question


We would like to know if anybody have the experience and would like to share in limiting the number of tags the user can input in the TAGS text field when he makes an question in .../questions/ask/ ?

Any help is greatly appreciated.

Thank you in advance!

  • aecnu
    • WP Unicorn

    Greetings Maick,

    Thank you for this great question and a significant item to bring up.

    Currently I do not know of anyone doing this, but I will let this ticket ride awhile to see what the community has to offer regarding this topic.

    Thank you for being a WPMU Dev Community Member!

    Cheers, Joe

  • Hakan
    • The Incredible Smush


    This is quite possible:

    // Save only first n tags
    function limit_qa_tags( $tags, $post ) {
    	// Max number of tags
    	$limit = 3;
    	$tags_arr = explode( ',', $tags );
    	if ( count( $tags_arr ) <= $limit )
    		return $tags;
    	$new_tags = '';
    	for ( $n=0; $n<$limit; $n++ ) {
    		$new_tags .= $tags_arr[$n] . ',';
    	return ( rtrim( $new_tags, ',' ) );
    add_filter( 'qa_before_add_tag', 'limit_qa_tags');

    Add these codes inside functions.php of your theme. It will save the first n tags, and ignore the rest. Change $limit as required.

    For advanced options you can check hooks in core/edit.php file of the plugin.


  • PC
    • WPMU DEV Initiate

    Greetings and thanks for being a great community member.

    We haven't heard from you on this one for long and I am doing a regular followup to see if there is still something we can assist you on this thread.

    Just to manage the support issues more efficiently, I am marking this thread as resolved for now however this is not being done to avoid your questions in any ways.

    Please feel free to mark this is "Not resolved" in case you have further questions and we would be back on it.

    Thanks a lot for being with WPMU DEV.

    Sales &Support

    Did you know we offer FREE lifetime memberships? Click here to learn more.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.