Home › Forums › Front-end Issues › Field Type "User", only show the posts that the "User" is selected › Reply To: Field Type "User", only show the posts that the "User" is selected
This is what I have so far and its not pulling any posts…
<?php
// args
$args = array(
'numberposts' => -1,
'post_type' => 'caregiver-updates',
'meta_key' => 'user_id',
'meta_value' => $current_user->ID
);
// get results
$the_query = new WP_Query( $args );
// The Loop
?>
<?php if( $the_query->have_posts() ): ?>
<ul>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
<?php wp_reset_query(); // Restore global post data stomped by the_post(). ?>
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.