Skip to:
Content
Pages
Categories
Search
Top
Bottom

Shortcode Topic – Add Reply Form


  • bm_kabin
    Participant

    @bm_kabin

    Hi guys, I’m using the [bbp-single-topic id=$topic_id] shortcode to include a topic on my post. Would it be possible to have the reply form above the topic? How would I modify the template to remove the displayed breadcrumb as well?

Viewing 12 replies - 1 through 12 (of 12 total)

  • Robin W
    Moderator

    @robin-w

    ok the template you are after is

    wp-content/bbpress/templates/default/bbpress/content-single-topic.php

    this will alter it wherever this template is used.

    make a copy of this template and put it in a directory called bbpress in the root of your theme, so you end up with

    wp-content/themes/%your-theme-name%/bbpress/content-single-topic.php

    where %your-theme-name% is the name of your theme

    Then modify this file

    to remove breadcrumbs take out line 14 which says

    <?php bbp_breadcrumb(); ?>

    then move line 44 (will probably be line 43 if you’ve taken out then breadcrumb!) which says

    <?php bbp_get_template_part( 'form', 'reply' ); ?>
    
    

    You may need to play with where to put it 9i haven’t tried it) , but after lines 21 & 22

    <?php bbp_get_template_part( 'form', 'protected' ); ?>
    
    	<?php else : ?>
    

    looks a good start, if not just keep moving it til you get what you want.

    If you only want it to look like this for the shortcode, then that is doable but a lot more complicated !


    bm_kabin
    Participant

    @bm_kabin

    Thanks Robin! No problem with the steps you have laid out so far. How would I isolate these changes only for the shortcode?


    Robin W
    Moderator

    @robin-w

    ok so if your code savvy, two approaches

    1. the hack

    I haven’t tried this, but it should work fine

    go into

    wp-content/plugins/bbpress/includes/common/shortcodes.php

    and look at line

    355 which says

    bbp_get_template_part( 'content', 'single-topic' );
    

    change that to

    bbp_get_template_part( 'content', 'single-topicb' );
    
    

    That will then get bbpress looking for a php file called ‘content-single-topicb.php’

    so then you can use the method in my first post to create that file in your theme ie as per first post, but just rename the file with a b at the end.

    YOU WILL need to change this each time bbpress upgrades as it will overwrite – hence why it is the hack ! But that’s hardly difficult !

    2. the proper way

    Would be to create your own version of the shortcode, by copying all that particular shortcode into your themes functions file, BUT renaming it (or you’ll get already loaded errors), and then lots of editing to get it to work.

    Personally I’d go route 1, and just make a note to change that file each time bbpress upgrades


    bm_kabin
    Participant

    @bm_kabin

    I’m gonna stick with the first method seeing there’s just too much work for a simple hack. Thanks again for the help Robin, really appreciate it!


    Robin W
    Moderator

    @robin-w

    no problem !


    bm_kabin
    Participant

    @bm_kabin

    Yikes I think I may have spoke a little too soon. Having done your recommended method, it doesn’t seem to isolate the changes made for the shortcode. I have removed the original modified file and created a duplicate named ‘content-single-topicb.php’. This corresponds with the change to line 335 in shortcodes.php with bbp_get_template_part( 'content', 'single-topicb' );.

    Any idea why it’s not working?


    Robin W
    Moderator

    @robin-w

    can you explain further?

    Do you have the changes but all over the site, or do you not have the changes anywhere?


    bm_kabin
    Participant

    @bm_kabin

    The modification does not limit to just the shortcode inclusion of the topic but on the forum as well. I thought it would have isolated but the changes seem to follow even on the default forum view?


    Robin W
    Moderator

    @robin-w

    It should work for just the shortcode, but let me test on my site


    Robin W
    Moderator

    @robin-w

    ok, interestingly (or not !) the forum code uses this shortcode.

    Ok so plan b !

    I’ve cut a quick new shortcode that looks for content-single-topicb.php

    you can download it from my site

    Topic shortcode

    use the shortcode

    [display-topic-special id=$topic_id]


    bm_kabin
    Participant

    @bm_kabin

    Sorry Robin, where would I add that shortcode?


    Robin W
    Moderator

    @robin-w

    sorry, you need to put it at the end of your functions file

    Functions files and child themes – explained !

Viewing 12 replies - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.
Skip to toolbar