Support

Account

Home Forums Front-end Issues Problem with Taxonomy Field

Helping

Problem with Taxonomy Field

  • Hi there,

    it seems like the solution for “Basic display (single value)” described here

    http://www.advancedcustomfields.com/resources/field-types/taxonomy/

    didn’t work.

    I have a field which is defined in PHP like this:

    array (size=18)
      'key' => string 'field_vehicle_ad_make' (length=21)
      'label' => string 'Make' (length=4)
      'name' => string 'make' (length=4)
      '_name' => string 'make' (length=4)
      'type' => string 'taxonomy' (length=8)
      'order_no' => int 1
      'instructions' => string '' (length=0)
      'required' => int 1
      'id' => string 'acf-field-make' (length=14)
      'class' => string 'taxonomy' (length=8)
      'conditional_logic' => 
        array (size=3)
          'status' => int 0
          'allorany' => string 'all' (length=3)
          'rules' => int 0
      'taxonomy' => string 'make' (length=4)
      'field_type' => string 'select' (length=6)
      'allow_null' => int 1
      'load_save_terms' => int 1
      'return_format' => string 'object' (length=6)
      'multiple' => boolean false
      'value' => 
        array (size=1)
          0 => 
            object(stdClass)[6256]
              public 'term_id' => int 594
              public 'name' => string 'Volkswagen' (length=10)
              public 'slug' => string 'volkswagen' (length=10)
              public 'term_group' => int 0
              public 'term_taxonomy_id' => int 604
              public 'taxonomy' => string 'make' (length=4)
              public 'description' => string '' (length=0)
              public 'parent' => int 0
              public 'count' => int 3
              public 'object_id' => int 1443
              public 'filter' => string 'raw' (length=3)
    

    the “field_type” is “select” as I only what 1 term for this taxonomy.

    but if I do the following:

    <?php 
     
    $term = get_field('field_vehicle_ad_make');
     
    if( $term ): ?>
     
    	<h2><?php echo $term->name; ?></h2>
    	<p><?php echo $term->description; ?></p>
     
    <?php endif; ?>

    I always get an array and not a single object.

    The documentation says:

    Basic display (single value)

    This example shows how to get and display a single term object. This would imply that your field type setting is checkbox or multi-select.

    But I think that doesn’t make any sense, “checkbox” or “multi-select” for a single term object.

    Is this a bug?

  • I may be having a similar issue. Have you tried for testing purposes, change the select to radio button? That seemed to be a quick work around for me.

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

You must be logged in to reply to this topic.