Home Forums ACF PRO Using ACF Pro to create Posts Grid Reply To: Using ACF Pro to create Posts Grid

  • You’re right, I misunderstood.

    You need to get the values of the fields and then add a tax query when queying posts. Since you are looking at possibly multiple taxonomies then it will be a little complicated.

    Set your fields to return term ID

    The basic code would look something like this

    $categories = get_field('my_category_field');
    // make sure it is an array, if only one is
    // selected it may return a single value
    if (!is_array($categories)) {
      $categories = array($categories);
    $tags = get_field('my_tags_field');
    if (!is_array($tags)) {
      $categories = array($tags);
    $args = array(
      'post_type' => 'post',
      'posts_per_page' => -1,
      'tax_query' => array(
        'relation' => 'OR',
          'taxonomy' => 'category',
          'terms' => $categories
          'taxonomy' => 'post_tag',
          'terms' => $tags
    $query = new WP_Query($args);

    For more information on tax_query see