Home › Forums › General Issues › Query Posts with WP_Query and grab ACF fields › Reply To: Query Posts with WP_Query and grab ACF fields
Are you trying to filter the posts that are returned by these fields or are you trying to somehow have the returned post array include the content of the fields?
The first is possible.
The second is not really possible. WP_Query does not return values from custom fields. To get these you must loop through the posts and get the values of the fields.
if ($featured_posts->have_posts()) {
while($featured_posts->have_posts()) {
$featured_posts->the_post();
$value = get_field('my_custom_field');
}
}
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.