How To Add “New Topic” button
-
In loop-fourms.php file add your custom “Add Topic” button:
<a href="/new-topic/?ForumId=<?php echo bbp_get_forum_id()?>">New Topic</a>
Add this code to a custom .php file or directly to your theme function.php file:
//BBpress New Topic Button // add_shortcode('wpmu_bbp_topic', 'wpmu_bbp_create_new_topic', 10); function wpmu_bbp_create_new_topic(){ if ( isset($_GET['ForumId']) ){ return do_shortcode("[bbp-topic-form forum_id=".$_GET['ForumId']."]"); }else{ return do_shortcode("[bbp-topic-form]"); } } //End BBpress New Topic Button //
Make sure you’ve created a custom page titled “new topic” with a friendly url of “new-topic”
Place the new shortcode we registered into this page:
[wpmu_bbp_topic]
This will automatically display contact create form of the selected forum if ID exists in the URL otherwise fall back to default shortcode.
You can see it in action on my site:
http://artofwargaming.net/forums/Hope this helps anyone who was looking to create a “new topic” button.
I can’t take credit for this, this was all thanks to the help of the guys over at WPMUDEV – Sajid, Anang, and Tyler.
- The topic ‘How To Add “New Topic” button’ is closed to new replies.