Skip to:
Content
Pages
Categories
Search
Top
Bottom

Remove commas between tag display

Viewing 4 replies - 1 through 4 (of 4 total)
  • @lissyhunnybee

    Participant

    It may not be the most elegant solution but the following worked for me….

    In your theme’s functions.php place this code:

    //* Remove Commas in BBPress Post Tag Display
    function my_bbp_topic_tag_list( $topic_id = 0, $args = '' ) {
    	echo my_bbp_get_topic_tag_list( $topic_id, $args );
    }
    
    function my_bbp_get_topic_tag_list( $topic_id = 0, $args = '' ) {
     
    		// Bail if topic-tags are off
    		if ( ! bbp_allow_topic_tags() )
    			return;
    
    		// Parse arguments against default values
    		$r = bbp_parse_args( $args, array(
    			'before' => '<div class="bbp-topic-tags"><p>' . esc_html__( 'Tagged:', 'bbpress' ) . '&nbsp;',
    			'sep'    => '',
    			'after'  => '</p></div>'
    		), 'get_topic_tag_list' );
     
    		$topic_id = bbp_get_topic_id( $topic_id );
    
    		// Topic is spammed, so display pre-spam terms
    		if ( bbp_is_topic_spam( $topic_id ) ) {
     
    			// Get pre-spam terms
    			$terms = get_post_meta( $topic_id, '_bbp_spam_topic_tags', true );
     
    			// If terms exist, explode them and compile the return value
    			if ( !empty( $terms ) ) {
    				$terms  = implode( $r['sep'], $terms );
    				$retval = $r['before'] . $terms . $r['after'];
     
    			// No terms so return empty string
    			} else {
    				$retval = '';
    			}
     
    		// Topic is not spam so display a clickable term list
    		} else {
    			$retval = get_the_term_list( $topic_id, bbp_get_topic_tag_tax_id(), $r['before'], $r['sep'], $r['after'] );
    		}
     
    		return $retval;
    	}

    Then copy bbpress\templates\default\bbpress\content-single-topic.php into your theme bbpress folder and replace <?php bbp_topic_tag_list(); ?> with <?php my_bbp_topic_tag_list(); ?>

    Hope that helps others looking to do the same thing, and if there’s a better solution let me know lol

    @robkk

    Moderator

    You could have done what most theme authors do with the post tag list when they are customizing it and replace <?php bbp_topic_tag_list(); ?> with something like this.

    <?php bbp_topic_tag_list( 0, array(
    	'sep'    => ''
    ) ); ?>

    @lissyhunnybee

    Participant

    I’m not a theme author or a coder, I just muddle through with what I find on Google for a lot of php stuff lol but I am learning every time someone shows me a better way to achieve something 🙂

    Thank you!

    @robkk

    Moderator

    no problem

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