Support

Account

Home Forums Front-end Issues Custom taxonomy slug not ID (again, i know) Reply To: Custom taxonomy slug not ID (again, i know)

  • Wow!
    Thanks for the super quick reply!

    Unfortunately it didn’t do the magic.
    Actually, pretty weird, your code (with the right field name “tecnica”) doesn’t output anything at all!

    My code is:

    <?php if( get_field('tecnica') ): ?>
    <?php $field_name = "text_field"; $field = get_field_object(tecnica); echo $field['label']; ?>:<?php the_field('tecnica'); ?>
    <?php endif; ?>

    (i need the label too, for possible future translations)

    I’ve set it to use radio button, because i need just one category (the tecnique used for a painting,it’s for a painter catalogue).

    I’ve tried to set as an html select, or a multiple category,and i get the array, but always with the id.

    The code you suggested with the correct field ‘tecnica’ is

    $terms = get_field('tecnica');
    
    // if you are expecting a single value
    if (is_array($terms)) {
     $term = $terms[0];
    }
    echo $term->name;
    
    // if you are expecting an array
    if (!is_array($terms)) {
      $terms = array($terms);
    }
    foreach ($terms as $term) {
      echo $term->name;
    }

    I’m working on Xaamp on my old laptop, PHP Version is 5.6.14…