Support

Account

Home Forums Front-end Issues Custom taxonomy show ID's instead of name

Solved

Custom taxonomy show ID's instead of name

  • So i’ve been looking for ever to get this to work. By I have a custom taxonomy “functie” that is liked to ACF “ook_inzetbaar_als”. I got this to work. But it only shows me the ID’s and not the names of the checked fields.

    Here is a screenshot of the ACF:
    ACF

    And here is the code that give me the ID’s but I want the Names.

    $ook = get_field('ook_in_zetbaar_als');
    <?php if( $ook): ?>
        <tr>
    	<td class="td-top"valign="top">Inzet:</td>
    	<td>
    	  <ul>
    	    <?php foreach( $ook as $ook ): ?>
    	      <li><?php echo $ook; ?></li>
    	    <?php endforeach; ?>
    	  </ul>
    	</td>
    </tr>
    <?php endif; ?>

    I’ve looked everywhere and tried all kinds of snippets.

    <a href="https://support.advancedcustomfields.com/forums/topic/get-custom-taxonomy-field-value/">
    </a>

    <a href="https://support.advancedcustomfields.com/forums/topic/how-to-display-taxonomy-labels/"></a>
    <a href="https://support.advancedcustomfields.com/forums/topic/taxonomy-in-repeater-field-shows-id/"></a>
    <a href="https://support.advancedcustomfields.com/forums/topic/custom-taxonomy-slug-not-id-again-i-know/"></a>
    <a href="https://support.advancedcustomfields.com/forums/topic/returning-custom-field-values-including-terms-on-term-archive-pages/"></a>

    But nothing works for me. Could you please help?

  • Hi @puur

    Demonstrated in this Taxonomy doc, you could change the line in your code where you create the “li” and echo $ook to be something like:

    
    <li><?php echo $ook->name; ?></li>
    

    In the same code on the above linked page, it also shows how to get the link and description.

    Hope that helps!
    Keith

  • Excellent! Thanks for the quick reply!

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

The topic ‘Custom taxonomy show ID's instead of name’ is closed to new replies.