Skip to:
Content
Pages
Categories
Search
Top
Bottom

Show forum description in forum list

  • @sdunning

    Participant

    I wish to show the description of each forum in the forum list as seen here:
    http://forum.unified-automation.com/

    If someone could point me towards the file and/or function I need to add/amend, I’d be eternally grateful.

    I have it laid out with the child forums listed as shown by following this example but when I last tried to show the description along side it, I got the WSOD (my php sucks).

    Thanks to any and all!

    WP version 4.0
    bbPress version 2.5.4

Viewing 5 replies - 1 through 5 (of 5 total)
  • @ezyridah

    Participant

    @sdunning, you can simply add text to the Forums page, where you create your forums / sub-forums.
    Add text the same way you do with Posts or Pages.

    @sdunning

    Participant

    Thanks for the reply @EzYRiDaH.

    Unfortunately that will not work in my case. If I navigate into the Parent forum, I am given the description of each child forum but I wish to display each description on my parent forum page. So far I am given the name along with number of topics and replies but not the description of the children.

    @robin-w

    Moderator

    I think this should do it. It’s from my library of code and haven’t used it in a while, so come back if it’s not what you want

    You’ll need to add it to your functions file

    Functions files and child themes – explained !

    //This function adds descriptions to the sub forums
    function custom_list_forums( $args = '' ) {
    
    	// Define used variables
    	$output = $sub_forums = $topic_count = $reply_count = $counts = '';
    	$i = 0;
    	$count = array();
    
    	// Parse arguments against default values
    	$r = bbp_parse_args( $args, array(
    		'before'            => '<ul class="bbp-forums-list">',
    		'after'             => '</ul>',
    		'link_before'       => '<li class="bbp-forum">',
    		'link_after'        => '</li>',
    		'count_before'      => ' (',
    		'count_after'       => ')',
    		'count_sep'         => ', ',
    		'separator'         => ', ',
    		'forum_id'          => '',
    		'show_topic_count'  => true,
    		'show_reply_count'  => true,
    	), 'list_forums' );
    
    	// Loop through forums and create a list
    	$sub_forums = bbp_forum_get_subforums( $r['forum_id'] );
    	if ( !empty( $sub_forums ) ) {
    
    		// Total count (for separator)
    		$total_subs = count( $sub_forums );
    		foreach ( $sub_forums as $sub_forum ) {
    			$i++; // Separator count
    
    			// Get forum details
    			$count     = array();
    			$show_sep  = $total_subs > $i ? $r['separator'] : '';
    			$permalink = bbp_get_forum_permalink( $sub_forum->ID );
    			$title     = bbp_get_forum_title( $sub_forum->ID );
    			$content = bbp_get_forum_content($sub_forum->ID) ;
    
    			// Show topic count
    			if ( !empty( $r['show_topic_count'] ) && !bbp_is_forum_category( $sub_forum->ID ) ) {
    				$count['topic'] = bbp_get_forum_topic_count( $sub_forum->ID );
    			}
    
    			// Show reply count
    			if ( !empty( $r['show_reply_count'] ) && !bbp_is_forum_category( $sub_forum->ID ) ) {
    				$count['reply'] = bbp_get_forum_reply_count( $sub_forum->ID );
    			}
    
    			// Counts to show
    			if ( !empty( $count ) ) {
    				$counts = $r['count_before'] . implode( $r['count_sep'], $count ) . $r['count_after'];
    			}
    
    			// Build this sub forums link
    			$output .= $r['before'].$r['link_before'] . '<a href="' . esc_url( $permalink ) . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $r['link_after'].'<div class="bbp-forum-content">'.$content.'</div>'.$r['after'];
    		}
    
    		// Output the list
    		return $output ;
    	}
    }
    
    add_filter('bbp_list_forums', 'custom_list_forums' );

    @sdunning

    Participant

    Thanks very much, @robin-w! That’s exactly what I needed! 🙂

    @robin-w

    Moderator

    Great – glad you’re fixed !

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