bbPress provides a powerful platform for creating forums on your WordPress site, but you might want to add custom categories to better organize the discussions. Here’s how to do it with a simple PHP code snippet:
function add_custom_forum_categories() {
$args = array(
'post_type' => 'forum',
'post_status' => 'publish',
'numberposts' => -1,
'orderby' => 'title',
'order' => 'ASC'
);
$custom_forums = get_posts( $args );
foreach ( $custom_forums as $forum ) {
// Custom logic to categorize forums
wp_set_post_categories( $forum->ID, array( 1, 2, 3 ) ); // example category IDs
}
}
add_action( 'bbp_new_forum', 'add_custom_forum_categories' );