I created a relationship between post to expert (post cpt). Author will create a expert that will link/relate to a post.
I'm trying to display the linked/related posts on the author archive page.
Im using the tutorial from metabox doc but getting a Invalid argument supplied for foreach()
error.
sample
<?php
$auid = get_the_author_meta( 'ID' );
$args = array(
'author' => '$auid',
'post_type' => 'post'
);
$my_query = new WP_Query( $args );
MB_Relationships_API::each_connected( [
'id' => 'expert-challenge',
'to' => $my_query->posts, // Set to $my_query.
] );
while ( $my_query->have_posts() ) : $my_query->the_post();
// Display connected pages
foreach ( $post->connected as $p ) :
echo $p->post_title;
// More code here.
endforeach;
echo '<pre>'; var_dump($my_query->posts) ; echo '</pre>';
endwhile;
//wp_reset_postdata();