[Plugin: Posts 2 Posts] Get connected posts of children
-
In this situation, I am using get_children to grab a post’s child pages and display them in a tabs. In each tab I’m trying to display the connected posts (in this case from a post type named “ship”).
The code below is pulling up posts from the right posts type, but the posts it grabs are not connected. In fact, it grabs the same posts even if I remove the “connected” parameter completely.
This might be obvious, but$child_idis the id of the main post’s child:$args = array( 'post_type' => 'ship', 'connected_to' => $child_id, ); $lastposts = get_posts( $args ); foreach($lastposts as $post) : setup_postdata($post); $permalink_ship = get_permalink( $post->id ); $shipid = $post->id; $meta .= "<a href=\"".$permalink_ship."\">".$post->post_title."</a><br/>"; endforeach;Oh, also this is what I have in my functions.php:
function my_connection_types() { if ( !function_exists('p2p_register_connection_type') ) return; p2p_register_connection_type( 'cruise', 'ship', true ); } add_action('init', 'my_connection_types', 100);Any ideas would be greatly appreciated…
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
The topic ‘[Plugin: Posts 2 Posts] Get connected posts of children’ is closed to new replies.