Title: [Plugin: Posts 2 Posts] P2P not working with custom post types?
Last modified: August 20, 2016

---

# [Plugin: Posts 2 Posts] P2P not working with custom post types?

 *  Resolved [protohominid](https://wordpress.org/support/users/protohominid/)
 * (@protohominid)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-p2p-not-working-with-custom-post-types/)
 * I have installed the P2P plugin and have verified that it’s working by using 
   the example code, connecting posts to pages. This works as expected, with the
   connections box showing up in the editor sidebar. However, when I try to connect
   two custom post types, it’s not showing up.
    I’ve created the two post types 
   using the “Types” plugin, if that makes a difference. Here’s the code I’m using
   in functions.php:
 *     ```
       function my_connection_types() {
       	// Make sure the Posts 2 Posts plugin is active.
       	if ( !function_exists( 'p2p_register_connection_type' ) )
       		return;
   
       	p2p_register_connection_type( array(
       		'name' => 'homes_to_communities',
       		'from' => 'homes',
       		'to' => 'communities'
       	) );
       }
       add_action( 'init', 'my_connection_types', 100 );
       ```
   
 * This plugin will be a perfect solution to my problem if I can get it to work…
   Thanks in advance!
 * [http://wordpress.org/extend/plugins/posts-to-posts/](http://wordpress.org/extend/plugins/posts-to-posts/)

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

 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-p2p-not-working-with-custom-post-types/#post-2506866)
 * Are you sure the actual names for the post types are ‘homes’ and ‘communities’,
   rather than ‘home’ and ‘community’?
 *  Thread Starter [protohominid](https://wordpress.org/support/users/protohominid/)
 * (@protohominid)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-p2p-not-working-with-custom-post-types/#post-2506868)
 * Yeah, I tried it that way as well, but no go. I also verified in the DB that 
   the “post_type” fields are indeed “communities” and “homes”. Anything else I 
   might be missing?
 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-p2p-not-working-with-custom-post-types/#post-2506871)
 * Does it work if you replace one of the post types with ‘post’?
 * Also, you could try adding `define( 'WP_DEBUG', true );` to your `wp-config.php`
   file to see if P2P generates any notices.
 *  Thread Starter [protohominid](https://wordpress.org/support/users/protohominid/)
 * (@protohominid)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-p2p-not-working-with-custom-post-types/#post-2506874)
 * Indeed, the debugger is throwing two errors that “Post type ‘homes’ is not defined”(
   a 2nd message says ‘communities’) in the “type-factory.php” file on line 35.
 * If I change the function to
 *     ```
       p2p_register_connection_type( array(
       		'name' => 'homes_to_pages',
       		'from' => 'homes',
       		'to' => 'page'
       	) );
       ```
   
 * the regular pages and posts are connected, but not the homes pages. Weird. And
   I’m still getting the error that ‘homes’ post type isn’t defined in p2p…
 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-p2p-not-working-with-custom-post-types/#post-2506877)
 * It seems the Types plugin registers the post types later. Try replacing ‘init’
   with ‘wp_loaded’.
 *  Thread Starter [protohominid](https://wordpress.org/support/users/protohominid/)
 * (@protohominid)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-p2p-not-working-with-custom-post-types/#post-2506878)
 * That got it! You rock, many thanks!!

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

The topic ‘[Plugin: Posts 2 Posts] P2P not working with custom post types?’ 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/)

 * 6 replies
 * 2 participants
 * Last reply from: [protohominid](https://wordpress.org/support/users/protohominid/)
 * Last activity: [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-p2p-not-working-with-custom-post-types/#post-2506878)
 * Status: resolved