bbPress

Simple, Fast, Elegant

bbPress support forums » Requests and Feedback

Tags separated with commas

(3 posts)
  • Started 1 year ago by NickBrady
  • Latest reply from NickBrady

Tags:

  1. 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;
    }

    Posted 1 year ago #
  2. 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.

    Posted 1 year ago #
  3. Hi, chrishajer

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

    Posted 1 year ago #

RSS feed for this topic

Reply

You must log in to post.

Code is Poetry.