Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_filter( 'bp_get_title_parts', 'boss_child_wp_title', 20 );
- /**
- * Add the topic title part into <title> tag, when viewing a topic in group forums.
- *
- * @global type $wpdb
- * @param array $title_parts
- * @return array
- */
- function boss_child_wp_title( $title_parts ){
- if( function_exists( 'bbp_get_topic_post_type' ) && function_exists( 'bp_is_group_forum_topic' ) && bp_is_group_forum_topic() ){
- $topic_slug = bp_action_variable( 1 );
- if( empty( $topic_slug ) )
- return $title_parts;
- //$topic = get_page_by_path( $topic_slug, OBJECT, bbp_get_topic_post_type() );
- global $wpdb;
- $topic_title = $wpdb->get_var( $wpdb->prepare(
- "SELECT post_title FROM {$wpdb->posts} WHERE post_type=%s AND post_name=%s",
- bbp_get_topic_post_type(),
- $topic_slug
- ) );
- if( empty( $topic_title ) || is_wp_error( $topic_title ) )
- return $title_parts;
- //$topic_title = wp_trim_words( $topic_title, 10 );//limit it to 10 words
- $new_parts = array( $topic_title );
- if( !empty( $title_parts ) ){
- foreach( $title_parts as $p ){
- $new_parts[] = $p;
- }
- }
- $title_parts = $new_parts;
- }
- return $title_parts;
- }
Add Comment
Please, Sign In to add comment