Displaying Multiple Connections
-
I’ve got several post types with p2p connections setup like this:
p2p_register_connection_type( array( 'name' => 'company_to_news', 'from' => 'company', 'to' => 'news', 'admin_box' => array( 'show' => 'to', 'context' => 'side', ), ) );
When I try to display all of the various post types that are connected to a “company” in the single-company.php page template with this code I am only getting 1 post type:
$connected_type = array( 'company_to_news', 'company_to_post', 'company_to_research', 'company_to_commentary', 'company_to_video', ); $connected_company = new WP_Query( array( 'connected_type' => $connected_type, 'connected_items' => get_queried_object_id(), ) );
However, when I set
$connected_type = ( 'company_to_news' );
or any of the other single connections I see the corresponding posts for each of the post types as expected. So I know they are all valid connections with associated posts.How can I query all of the different connected post types instead of just a single type?
The release notes on version 1.2 of the p2p plugin says,
“Also, you can pass an array of connection types and P2P will pick the ones that make sense.”
How do we get p2p to use all the connections in the array instead of just the ones it thinks make sense?
- The topic ‘Displaying Multiple Connections’ is closed to new replies.