Bbpress – Add New Topic Button

  • Participant
    Level: Enlightened
    Posts: 118
    Erich199 on #1417

    For those members who use bbpress and want to add a “new topic” button, I have hunted/searched/asked all over the internet and I’ve finally come up with a solution with some help of coders at WPMUDEV and here it is:

    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']."]");
    		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:


    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:

    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.

    • This topic was modified 8 years, 5 months ago by Erich199.
    • This topic was modified 8 years, 5 months ago by Erich199.
    • This topic was modified 8 years, 5 months ago by Erich199.
  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #1422

    Hi Joshua,
    Welcome to the BuddyDev forums 🙂

    Thank you for sharing the code, I am sure may community members will find it useful.
    I highly appreciate sharing the knowledge 🙂

    Thank you

You must be logged in to reply to this topic.

This topic is: not resolved