Combine the results of two loops [closed]

Yes it is. First you have to combine the results in one array: $all_posts = array_merge( $related->posts, $features->posts ); Now, let’s sort the array items by date: usort( $all_posts, function( $a, $b ) { return strcmp( $b->post_date, $a->post_date ); } ); Finally, do the loop: global $post; foreach ( $all_posts as $post ) { setup_postdata( … Read more

Post 2 Post: Getting connected ‘person’ from post author

On single post, try something like this: $author_id = get_the_author_meta(‘ID’); $people = get_posts( array( ‘connected_type’ => ‘people_to_user’, // replace with whatever ‘connected_items’ => $author_id, ‘suppress_filters’ => false, ‘nopaging’ => true ) ); Now $people[0] references the first (and only) author related to the post you’re on. So $people[0]->ID can be used to get the various … Read more

One-to-many post relationships that are displayed by category (using posts-to-posts plugin)

I’m not that familiar with the posts-to-posts Plugin, but your main problem may be that the category page doesn’t know which building you chose in the step before if you don’t transmit it in a parameter or save it in a session or cookie. Maybe it would be better to output the connected items on … Read more

[Plugin: Posts 2 Posts] Controling the display order of connections

With the development version of the plugin (0.8-alpha), you have a ‘p2p_orderby’ query var, which you can use with WP_Query, like so: $my_query = new WP_Query( array( ‘connected_to’ => get_queried_object_id(), ‘p2p_orderby’ => ‘my_connection_field’ ) ); More info on connection fields: https://github.com/scribu/wp-posts-to-posts/wiki/Connection-information Note that this is alpha software and you still have some work to do … Read more