To store the values of the $tags variable in the ‘topic-tag’ taxonomy when creating a new bbPress topic

To store the values of the $tags variable in the ‘topic-tag’ taxonomy when creating a new bbPress topic. This parameter is used to assign terms from taxonomies to a post during its creation.
To make sure that the tags are kept in the ‘topic tag’ taxonomy, use the following code to input the value to tag in the bbp_insert_topic call:

// Create a new bbPress topic with the specified author (bbp_author_id)
$topic_id = bbp_insert_topic(array(
    'post_title' => $title,
    'post_content' => $content,
    'tax_input' => array('topic-tag' => array($tags)), // Use an array to store multiple tags
    'post_parent' => $forum,
    'post_author' => $user_id, // Set the author ID
    // Add more parameters as needed
));

Leave a comment

Your email address will not be published. Required fields are marked *