Home › Forums › General Issues › Working with Post Object in relation to User › Reply To: Working with Post Object in relation to User
I changed over to Relationship as Post Object and that got me what I needed.
Here is a sample that might help get you started.
$author_id = get_the_author_meta('ID');
$posts = get_field('field1_name', 'user_'. $author_id);
if( $posts ):
foreach( $posts as $post): // variable must be called $post (IMPORTANT)
setup_postdata($post);
echo '<a href="' . the_permalink() . '">' . the_title() . '</a>';
the_field('field2_name');
the_excerpt();
endforeach;
wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly
Maybe this helps someone else.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.