1

I have created a custom taxonomy called inn-features, I have then created a template page, whenever I try to show my custom fields the value always returns as null. Please can someone tell me where I am going wrong.

This is a really simplified version of the code as I stripped everything out to see where I am going wrong but I can't figure it out.

The var dump for each displays the following

<?php
/**
 * The template for displaying taxonomy archive pages
 *
 */



// get the current taxonomy term
$queried_object = get_queried_object(); 
$taxonomy = $queried_object->taxonomy;
$term_id = $queried_object->term_id;  



// vars
$test = get_field('test_text', $taxonomy);

    var_dump($queried_object);

    var_dump($taxonomy);

    var_dump($term_id);

    var_dump($test);

    ?>

$queried_object, $taxonomy & $term_id all return values it is purely $test that returns null.

Jay
  • 346
  • 1
  • 3
  • 18

2 Answers2

2

I eventually sorted it out by doing:

$term = get_queried_object();

$test = get_field('test_text',$term);

This fixed it for me.

Jay
  • 346
  • 1
  • 3
  • 18
0

You need to use a post ID for the 2nd parameter.

Per ACF's Doc:

get_field($selector, [$post_id], [$format_value]);

So you need to loop through the posts in the taxonomy, then display the custom fields per post.

ACF get_field

KGreene
  • 790
  • 7
  • 11