Title: [Plugin: Posts 2 Posts] Conflict with plugin filtering the_title()
Last modified: August 20, 2016

---

# [Plugin: Posts 2 Posts] Conflict with plugin filtering the_title()

 *  Resolved [owenwalz](https://wordpress.org/support/users/owenwalz/)
 * (@owenwalz)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-conflict-with-plugin-filtering-the_title/)
 * Hi Scribu,
 * I’ve added a snippet of code to my functions that pulls the title for custom 
   post type ‘person’ from a combination of their first and last names (meta values).
   Unfortunately this filter seems to be confusing the p2p meta boxes. In the edit
   post screen they now show all connected posts with the same name of the post 
   currently open for editing. The snippet I’m using is:
 *     ```
       function theme_slug_filter_the_title( $title ) {
           global $post;
           if ( 'person' == get_post_type( $post ) ) {
           	$custom = ( get_post_custom( $post->ID ) ? get_post_custom( $post->ID ) : false );
           	$custom_title = ( isset( $custom['person_name_first'][0] ) && isset( $custom['person_name_last'][0] ) ? $custom['person_name_first'][0]  . " " . $custom['person_name_last'][0]: '(No Name)' );
           	return $custom_title;
          	} else {
               return $title;
           }
       }
       add_filter( 'the_title', 'theme_slug_filter_the_title' );
       ```
   
 * Is there a way I should modify this to make it more compatible with p2p?
 * Thanks,
    O
 * [http://wordpress.org/extend/plugins/posts-to-posts/](http://wordpress.org/extend/plugins/posts-to-posts/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-conflict-with-plugin-filtering-the_title/#post-3022172)
 * The problem is that you’re using the $post global, instead of using the post 
   id passed to the ‘the_title’ filter:
 *     ```
       function theme_slug_filter_the_title( $title, $post_id ) {
           $post = get_post( $post_id );
   
           if ( 'person' == get_post_type( $post ) ) {
           ...
       }
       add_filter( 'the_title', 'theme_slug_filter_the_title', 10, 2 );
       ```
   
 *  Thread Starter [owenwalz](https://wordpress.org/support/users/owenwalz/)
 * (@owenwalz)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-conflict-with-plugin-filtering-the_title/#post-3022185)
 * Thanks so much. That worked perfectly.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘[Plugin: Posts 2 Posts] Conflict with plugin filtering the_title()’ is
closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/posts-to-posts_7a8e9d.svg)
 * [Posts 2 Posts](https://wordpress.org/plugins/posts-to-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/posts-to-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/posts-to-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/posts-to-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/posts-to-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/posts-to-posts/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [owenwalz](https://wordpress.org/support/users/owenwalz/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-conflict-with-plugin-filtering-the_title/#post-3022185)
 * Status: resolved