Title: [Plugin: Posts 2 Posts] Can&#039;t get example to work
Last modified: August 19, 2016

---

# [Plugin: Posts 2 Posts] Can't get example to work

 *  Resolved [MWM](https://wordpress.org/support/users/mike235/)
 * (@mike235)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-posts-2-posts-cant-get-example-to-work/)
 * Hi,
 * Thanks for another great plugin, the possibilities of P2P are great. But I’m 
   having some trouble making it work.
 * I did the following, on a blank WP (3.1.1) and P2P (0.7), my PHP version is 5.3.3:
 * Created a custom post type named : publications
 * Then in functions.php :
 *     ```
       function my_connection_types() {
       	if ( !function_exists( 'p2p_register_connection_type' ) )
       		return;
   
       	p2p_register_connection_type( array(
       		'from' => 'publications',
       		'to' => 'page'
       	) );
       }
       add_action( 'init', 'my_connection_types', 100 );
       ```
   
 * and in page.php :
 *     ```
       $connected = new WP_Query( array(
       	'post_type' => 'publications',
       	'connected_from' => get_queried_object_id()
       ) );
   
       echo '<p>Related posts:</p>';
       echo '<ul>';
       	while( $connected->have_posts() ) : $connected->the_post();
       		echo '<li>';
       		the_title();
       		echo '</li>';
       	endwhile;
       echo '</ul>';
   
       wp_reset_postdata();
       ```
   
 * This is exactly the examples from the wiki, I just adapted it to a custom post
   type. But it doesn’t work, all it shows is : “Related posts:”
 * Am I missing something ?

Viewing 1 replies (of 1 total)

 *  Thread Starter [MWM](https://wordpress.org/support/users/mike235/)
 * (@mike235)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-posts-2-posts-cant-get-example-to-work/#post-2045027)
 * Ok I got the answer [here](http://wordpress.stackexchange.com/questions/15456/ho-does-scribus-posts-2-posts-work/).
 * It turns out you need to write :
 * `connected' => get_queried_object_id()`
 * instead of :
 * `connected_from' => get_queried_object_id()`
 * Now I’m very excited to play with P2P, as Scribu says the possibilities are endless!

Viewing 1 replies (of 1 total)

The topic ‘[Plugin: Posts 2 Posts] Can't get example to work’ 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/)

## Tags

 * [custom post type](https://wordpress.org/support/topic-tag/custom-post-type/)

 * 1 reply
 * 1 participant
 * Last reply from: [MWM](https://wordpress.org/support/users/mike235/)
 * Last activity: [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-posts-2-posts-cant-get-example-to-work/#post-2045027)
 * Status: resolved