I have a custom taxonomy called projects that has a custom post type called apartments, both have acf custom fields.

I want to bring the taxonomy created projects with their acf fields on a certain page, example project 1, project 2.

I have created taxonomy-projects_apartments.php and used it as a template, for a page called projects.

$args = array(
    'taxonomy'     => 'projects',
    'orderby'      => $orderby,
    'show_count'   => $show_count,
    'pad_counts'   => $pad_counts,
    'hierarchical' => $hierarchical,
    'title_li'     => $title

wp_list_categories( $args ); 

This only brings the names, project 1 and project 2. On the single project page I use:

$queried_object = get_queried_object();
$taxonomy = $queried_object->taxonomy;
$term_id = $queried_object->term_id;

// load content for this taxonomy term
$custom_field = get_field('insert_new_project', 'projects' . '_' . $term_id);

to bring custom fields, and it works.

But queried objects brings the current page object, and does not work in the way I needed it to.

Any suggestions ?

  • What's the stored data in %term_meta table against the $term_id in database? Sort 'em there first, then try the ACF. It'll make the process less buggy. Commented Jun 24, 2018 at 14:59
  • OK, wait... So what exactly are you trying to achieve? What custom fields are there? What objects are there assigned for? And where do you want to display what...? Commented Jun 24, 2018 at 21:05
  • Updated code: $newargs = array( 'post_type' => 'apartamente', 'tax_query' => array( array( 'taxonomy' => 'projects', 'field' => 'slug', ) ) ); $the_query2 = new WP_Query( $newargs );
    – Marius
    Commented Jun 25, 2018 at 13:09

1 Answer 1


Updated code:

                                                                                                       $newargs = array(
        'post_type' => 'apartments',
        'tax_query' => array(
                'taxonomy' => 'projects',
                'field' => 'slug',

    $the_query = new WP_Query( $newargs );

<?php if ( $the_query->have_posts() ) : ?>

 //The query returns 0, if I use a taxonomy, for post types it works, and I can bring all ACF fields to that post. But I want also want taxonomy acf fields here.
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

//Custom field that Is inserted into apartments custom post type

 <?php while ( have_rows( 'assign_apartment_project') ) : the_row(); ?>

<?php endwhile; ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>

<?php endif; ?>       

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.