Skip to content

Instantly share code, notes, and snippets.

@daggerhart
Last active March 6, 2018 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save daggerhart/936efae067fade1bec00 to your computer and use it in GitHub Desktop.
Save daggerhart/936efae067fade1bec00 to your computer and use it in GitHub Desktop.
bbPress - remove "Reply To: " from reply post titles
<?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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment