Skip to content

Array returned for p2p_type( $connection_type)->get_adjacent_items($id); changes even when using the same post id! #356

Open
@dawnbuie

Description

@dawnbuie

I've written a function to output the associated series for all posts on my site. I feed in the ID of the post and use the following to test for a series.

$items_in_series = p2p_type( $connection_type)->get_adjacent_items($id);

It works perfectly for all but one set of posts generated by YARPP (yet another related posts plugin). The weird thing is I'm just sending the ID of the post now - not the post object - thinking this would fix my problem. It didn't.

When I print_r($items_in_series)

the post the correctly outputs its associated series title says:

Array ( [parent] => WP_Post Object ( [ID] => 1286 [post_author] => 1 [post_date] => 2013-03-10 22:50:54 
...

 [post_parent] => 0 [guid] => http://demo5c.riotwire.com/?post_type=cartoon&p=2030 [menu_order] => 0 [post_type] => cartoon [post_mime_type] => [comment_count] => 0 [filter] => raw [p2p_id] => 81 [p2p_from] => 2030 [p2p_to] => 1286 [p2p_type] => cartoon_to_series ) ) 

whereas the post that won't return its associate series title says:

Array ( [0] => from [1] => P2P_Item_Post Object ( [item:protected] => WP_Post Object ( [ID] => 1532 [post_author] => 8 [post_date] => 

...

[post_parent] => 0 [guid] => http://demo5c.riotwire.com/?post_type=cartoon&p=1532 [menu_order] => 0 [post_type] => cartoon [post_mime_type] => [comment_count] => 0 [filter] => raw [score] => 14.9 ) ) ) 

Somehow I don't think I'm passing the post ID properly - that the Post object is being sent instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions