Created
June 13, 2016 05:53
-
-
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.
This file contains hidden or 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
/** | |
* 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