[Plugin: Posts 2 Posts] Using p2p with get_posts
-
The plugin works great with wp_query, but I’m unable to get it to work using get_posts
My code is as follows:
`$countryargs =array(
‘orderby’ => ‘title’,
‘order’ => ‘ASC’,
‘post_type’ => ‘country’,
‘posts_per_page’=>-1,
‘each_connected’ => array(
‘post_type’ => ‘distributor’
));$loop = get_posts( $countryargs);
foreach ($loop as $post) : setup_postdata($post);
`
and then get connected posts with
foreach ( $post->connected as $distributor )
but I get
Warning: Invalid argument supplied for foreach() in /…path…/template_wheretobuy.php on line 67
on the line trying to get connected posts
What should I do?
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘[Plugin: Posts 2 Posts] Using p2p with get_posts’ is closed to new replies.