Home Forums ACF PRO Return Taxonomy Slug using Taxonomy Field Reply To: Return Taxonomy Slug using Taxonomy Field

  • basically, if you want to get all of the posts in a term then you should use WP_Query and the documentation will lead you there

    The important bit is the tax_query and the fact that your field is returning an term object. You could query by any of the fields of the returned object.

    If you want to see what the object looks like

    $department = get_field('department');
    echo '<pre>'; print_r($depearment'); echo '</pre>';

    Here is

      $department = get_field('department');
      $query = array(
        'post_type' => 'staff',
        'orderby' => 'menu_order',
        'order' => 'ASC',
        'posts_per_page' => -1,
        'tax_query' => array(
            'taxonomy' => 'departments',
            'field' => 'term_id', // not needed, default value
            'operator' => 'IN', // not needed, default value
            'terms' => array($department->term_id)
      $team_query = WP_Query($args);
      if ($team_query->have_posts()) {
        while($team_query->have_posts()) {
          // output stuff about this post

    more information about querying based on different types of acf fields can be fount here