Skip to:
Content
Pages
Categories
Search
Top
Bottom

Tags separated with commas


  • nickbrady
    Member

    @nickbrady

    Hi,

    I wanted to have tags separated by commas instead of spaces, to allow users to write tags with more than word.

    I did two very small changes to the function add_topic_tags() in the file functions.php and it works, here it goes in case someone is interested:

    function add_topic_tags( $topic_id, $tags ) {

    global $bbdb;

    $tags = trim( $tags );

    $words = preg_split(“/[,]+/”, $tags); // removed s

    if ( !is_array( $words ) )

    return false;

    foreach ( $words as $tag ) :

    add_topic_tag( $topic_id, trim($tag) ); // added trim()

    endforeach;

    return true;

    }

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

  • chrishajer
    Participant

    @chrishajer

    Hi Nick. Can you say if this works for adding a new topic and also when adding tags to an existing topic? And also, do you have an example of where this is running?

    Thanks.


    nickbrady
    Member

    @nickbrady

    Hi, chrishajer

    In the tests we have done, it does work adding a new topic and also adding new tags to an existing topic.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar