Skip to content

Instantly share code, notes, and snippets.

@r-a-y
Created June 13, 2016 05:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r-a-y/c9eb7c7f5bff2afb271a9b1edbf56a59 to your computer and use it in GitHub Desktop.
Save r-a-y/c9eb7c7f5bff2afb271a9b1edbf56a59 to your computer and use it in GitHub Desktop.
Use page title as set in admin area on BP directory pages.
/**
* Use page title for BP directory pages.
*/
function my_set_bp_page_title() {
// Check to see if current reset post is a BP directory; if not, bail.
if ( false == in_array( $GLOBALS['post']->ID, bp_core_get_directory_page_ids() ) ) {
return;
}
// Use WP page title for the_title().
$GLOBALS['post']->post_title = get_post_field( 'post_title', $GLOBALS['post']->ID );
}
add_action( 'bp_template_include_reset_dummy_post_data', 'my_set_bp_page_title', 50 );
/**
* Use page title for <title> tag on BP directory pages.
*/
function my_set_document_title( $title ) {
// Not a BP directory page? Bail.
if ( false === bp_is_directory() ) {
return $title;
}
// Set page title to use post title.
return $GLOBALS['post']->post_title;
}
add_filter( 'bp_get_directory_title', 'my_set_document_title' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment