Skip to:
Content
Pages
Categories
Search
Top
Bottom

How can I add a button next to favorite and subscribe buttons on a forum post?

  • @izzyian

    Participant

    How can I add a button next to favorite and subscribe buttons on a forum post? Iv searched everywhere and cant find a similar question. Is there a functions code I could add?

Viewing 6 replies - 1 through 6 (of 6 total)
  • @robkk

    Moderator

    you can use any of these hooks to add a button there using a function

    add_action( 'bbp_theme_after_topic_subscription_action' ); 
    
    add_action( 'bbp_theme_before_topic_subscription_action' ); 
    
    add_action( 'bbp_theme_after_topic_favorites_action' ); 
    
    add_action( 'bbp_theme_before_topic_favorites_action' ); 

    more info on using action hooks

    Step by step guide to setting up a bbPress forum – part 4

    @izzyian

    Participant

    @robkk,

    Thank you for that here is a little more info because i don’t understand where to place that code:

    What I want to do is add a button ( which I will later style in my css) that will just take the user back to the forum (basically a button that is a breadcrumb).

    I would place all the information here but bbpress reply box is not letting me for some reason. But you can read the information here where I placed it in the wrong section before I asked it here https://buddypress.org/support/topic/how-do-i-add-a-button-in-loops-replies-php-file/

    @robkk

    Moderator

    well i think i got all of those add action things wrong 🙁

    i got confused with them and thought they were before the favorte/subscription links

    but they were for the user favorites/subscription lists on their profile.

    this function should show it but it will be before the replies loop this function should be in your functions.php in your child theme

    function rkk_forum_link_before_replies() {
    
     if ( bbp_is_single_topic() ) {
    
        	?>
    		
        <a class="bbp-backto-forum" href="<?php bbp_forum_permalink(); ?>">Back to <?php bbp_forum_title(); ?></a>
     
        	<?php
    
        }
    
    }
    
    add_action( 'bbp_template_before_replies_loop', 'rkk_forum_link_before_replies' );

    this is for manually putting the link before the favorite link in loop-replies.php template file in your child theme.

    <a class="bbp-backto-forum" href="<?php bbp_forum_permalink(); ?>">Back to <?php bbp_forum_title(); ?></a>

    @izzyian

    Participant

    Wow thank you so much ! 🙂 … This is my loop replies php with the code in it, but I dont know if I put it in right because even though it shows, it does not appear in the same row as subscribe and favorites but rather a little above the row, and any css i added did not help.

    <?php do_action( 'bbp_template_before_replies_loop' ); ?>
    
    <div id="topic-post-list" class="item-list" role="main">
    
    <div class="forum-head-reply-tools">
    
     <a class="bbp-backto-forum" href="<?php bbp_forum_permalink(); ?>">Back to <?php bbp_forum_title(); ?></a> <?php bbp_user_subscribe_link('before=&nbsp;'); ?> <?php bbp_user_favorites_link(); ?></div>
    <div class="clear"></div>
    
    <ul>
    		<?php while ( bbp_replies() ) : bbp_the_reply(); ?>
    
    			<?php bbp_get_template_part( 'loop', 'single-reply' ); ?>
    
    		<?php endwhile; ?>
    </ul>
    </div><!-- #topic-<?php bbp_topic_id(); ?>-replies -->
    
    <?php do_action( 'bbp_template_after_replies_loop' ); ?>

    Here is a picture of the row so you can see the new button is a little above the row
    http://bitfiu.com/wp-content/uploads/2014/12/button-example.png

    @robkk

    Moderator

    well also put this if statement around the link so that it woulnt show in the users topic favorites/subsritions/started lists

    <?php if ( bbp_is_single_topic() ) : ?>
    
    <a class="bbp-backto-forum" href="<?php bbp_forum_permalink(); ?>">Back to <?php bbp_forum_title(); ?></a>
    	
    <?php endif; ?>

    the link looking a little off maybe because the developer of your theme customized it so that the css would affect it like this

    div.forum-head-reply-tools a {

    so that any link would be affected the same

    maybe removing the class in the code i gave you would fix that??

    so maybe like this

    <?php if ( bbp_is_single_topic() ) : ?>
    
    <a href="<?php bbp_forum_permalink(); ?>">Back to <?php bbp_forum_title(); ?></a>
    	
    <?php endif; ?>

    @izzyian

    Participant

    Thank you so much I found that the following css fixed my problem while using the 1st functions if then statement code

    a.bbp-backto-forum {
        margin-right: 8px;
    }
    #subscription-toggle, #favorite-toggle {
        display: block;
        float: right;
        padding-right: 8px !important;
        padding-top: 0 !important;
    }
Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Skip to toolbar