• It would be great to be able to set the “freshness” to display the title of the latest post, instead of a date as this would be better for SEO.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Robin W

    (@robin-w)

    Sorry for the delay in replying – I’ve been tied up on other things.

    Yes a great idea!

    To change it to title, put this in your functions file

    function rw_custom_freshness_link( $forum_id = 0 ) {
    		$forum_id  = bbp_get_forum_id( $forum_id );
    		$active_id = bbp_get_forum_last_active_id( $forum_id );
    		$link_url  = $title = '';
    
    		if ( empty( $active_id ) )
    			$active_id = bbp_get_forum_last_reply_id( $forum_id );
    
    		if ( empty( $active_id ) )
    			$active_id = bbp_get_forum_last_topic_id( $forum_id );
    
    		if ( bbp_is_topic( $active_id ) ) {
    			$link_url = bbp_get_forum_last_topic_permalink( $forum_id );
    			$title    = bbp_get_forum_last_topic_title( $forum_id );
    		} elseif ( bbp_is_reply( $active_id ) ) {
    			$link_url = bbp_get_forum_last_reply_url( $forum_id );
    			$title    = bbp_get_forum_last_reply_title( $forum_id );
    		}
    
    		$time_since = bbp_get_forum_last_active_time( $forum_id );
    
    		if ( !empty( $time_since ) && !empty( $link_url ) )
    			$anchor = '<a href="' . esc_url( $link_url ) . '" title="' . esc_attr( $title ) . '">' . esc_attr( $title ) . '</a>';
    		else
    			$anchor = esc_html__( 'No Topics', 'bbpress' );
    
    		return apply_filters( 'rw_get_forum_freshness_link', $anchor, $forum_id, $time_since, $link_url, $title, $active_id );
    	}
    
    	add_filter('bbp_get_forum_freshness_link', 'rw_custom_freshness_link' );

    If you want to display it as well use

    function rw_freshness_display_title ($forum_id = 0) {
    	// Verify forum and get last active meta
    	$forum_id  = bbp_get_forum_id( $forum_id );
    		$active_id = bbp_get_forum_last_active_id( $forum_id );
    		$link_url  = $title = '';
    
    		if ( empty( $active_id ) )
    			$active_id = bbp_get_forum_last_reply_id( $forum_id );
    
    		if ( empty( $active_id ) )
    			$active_id = bbp_get_forum_last_topic_id( $forum_id );
    
    		if ( bbp_is_topic( $active_id ) ) {
    			$link_url = bbp_get_forum_last_topic_permalink( $forum_id );
    			$title    = bbp_get_forum_last_topic_title( $forum_id );
    		} elseif ( bbp_is_reply( $active_id ) ) {
    			$link_url = bbp_get_forum_last_reply_url( $forum_id );
    			$title    = bbp_get_forum_last_reply_title( $forum_id );
    		}
    
    		$anchor = '<a href="' . esc_url( $link_url ) . '" title="' . esc_attr( $title ) . '">' . esc_html( $title ) . '</a>';
    		echo $anchor.'<p/>' ;
    
    }
    
    add_action( 'bbp_theme_before_forum_freshness_link', 'rw_freshness_display_title');

    I’ll add these to my ‘bbp style pack’ plugin as they would fit better there, but may be a couple of weeks before I do

    Thread Starter semperaye

    (@semperaye)

    Wow cool, can’t wait 🙂

    Plugin Author Robin W

    (@robin-w)

    now added to bbp-style-pack, but further refinements to come !

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Great but may I make a suggestion?’ is closed to new replies.