Remove “Reply To:” from bbPress Reply Titles

When loading replies from bbPress, a filter is applied to the_title that prepends the string “Reply To:” to the beginning of the reply’s topic title. Below is code that removes the filter, and adds a new one without the offending string.

<?php
/*
 * Filter for bbpress reply post_title, without "Reply To: " prefix
 * - reference: https://bbpress.trac.wordpress.org/browser/trunk/src/includes/replies/template.php
 */
function custom_bbp_get_reply_title_fallback( $post_title = '', $post_id = 0 ){
  // Bail if title not empty, or post is not a reply
  if ( ! empty( $post_title ) || ! bbp_is_reply( $post_id ) ) {
    return $post_title;
  }
  
  // Get reply topic title.
  $topic_title = bbp_get_reply_topic_title( $post_id );
  // Get empty reply title fallback.
  $reply_title = sprintf( __( '%s', 'bbpress' ), $topic_title );  
  
  return apply_filters( 'bbp_get_reply_title_fallback', $reply_title, $post_id, $topic_title );  
}
// add custom filter
add_filter( 'the_title', 'custom_bbp_get_reply_title_fallback', 2, 2);
// remove bbpress default filter
remove_filter( 'the_title', 'bbp_get_reply_title_fallback', 2);
3 Thoughts

Discussion

craigmccollKanjipad
May 5, 2015

Thanks, worked perfectly.

Ahmad Jarkas
June 14, 2018

Hi Jonathan,

Thank you for sharing your code.
I have copied and pasted your code on my Theme functions.php, but the string “Reply To:” has not disappeared.
Should I change something else?

Many thanks
Ahmad

Matt
November 11, 2018

Try removing lines 1-5 … that worked for me.

Matt
November 11, 2018

Just what I was looking for. Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *