Support

Account

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');
      }
    }