Support

Account

Home Forums General Issues Get fields on taxonomy

Solved

Get fields on taxonomy

  • Hi,

    I created a custom Taxonomy and attached a checkbox field to it. Now I’m struggling to retrive the data, get_field() returns false. The fields are correctly saved through the UI panel.

    function selectArchetype()
    {
      $terms = get_terms([
          'taxonomy' => 'archetype',
          'hide_empty' => false,
      ]);
    
      foreach ($terms as $term) {
        $fields = get_field('must_have_cards', $term->slug );
        var_dump($fields);
        }
    }
    

    Any idea would be appreciated. Thanks.

  • Hi @brevalessio

    Thanks for the post.

    I would recommend that you pass the actual $term object like so:

    function selectArchetype()
    {
      $terms = get_terms([
          'taxonomy' => 'archetype',
          'hide_empty' => false,
      ]);
    
      foreach ($terms as $term) {
        $fields = get_field('must_have_cards', $term);
        var_dump($fields);
        }
    }
  • Yeah, thanks, this solved my question.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Get fields on taxonomy’ is closed to new replies.