[Plugin: Posts 2 Posts] Ordering BY connected posts
-
What I’m doing:
A search results page. Currently it grabs a bunch of posts two different ways, both using the connected_to argument for query_posts. Here’s an example:
Search 1:$args = array( 'post_type' => 'my-type', 'connected_to' => $_GET['some-other-type_ID'] );
and my other search
$args = array( 'post_type' => 'my-type', 'connected_to' => $_GET['some-other-OTHER-type_ID']
This works great at getting the posts that are connected…however I need them to be ordered by the connected post’s ID. So I tried using the p2p_to parameter as a meta_key and orderby meta_value_num but then soon realized that p2p_to is not a meta value. I’m not seeing any other way to do this other than getting the posts and THEN doing a custom sort myself using the p2p_id and then printing them.
My other concern is that on the second search I’m doing, I still want to sort by ‘some-other-type’ even though I’m getting the connected_to from ‘some-other-OTHER-type’. The posts I’m printing out are connected to both types always, so the connection always exists for sorting on, even though I didn’t use it for ‘connected_to’.
Wow, this sounds complex!
Is there an easier way to do this by using the Posts 2 Posts api that I’m not seeing? Thanks for any help.
- The topic ‘[Plugin: Posts 2 Posts] Ordering BY connected posts’ is closed to new replies.