Last active
March 6, 2018 11:42
-
-
Save daggerhart/936efae067fade1bec00 to your computer and use it in GitHub Desktop.
bbPress - remove "Reply To: " from reply post titles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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