Support

Account

Home Forums General Issues Display list of taxonomy ID's and information linked to each ID

Solved

Display list of taxonomy ID's and information linked to each ID

  • Hi !
    I’m actually working on a website using the ACF Plugin. It works great but I’m stucked with something quite particular I want to do.

    First, I’m using another plugin, called CPT-onomies, which lets me use custom posts as taxonomies.

    On my website, I want to create events in which I can select multiple hosts (Hosts are a custom post type, but also taxonomies thanks to CPT-onomies). For some specific reason I want to use ACF Plugin and not the traditional way to select a taxonomies in a post. I’ve created a Taxonomy field via ACF, and then selected 3 hosts.

    Now, what I want to do is to call the list of taxonomies selected in the post via ACF, and get the ID of each taxonomy so I can use it to get more data from the custom post it is attached to.

    I’ve tried this code but it doesn’t show anything :

    <?php $values = get_field('animateurs_event');
    foreach($values as $value){
    echo '<li>'.$value.'</li>'; 
    } ?>

    I’ve done a vardump and the only thing I get is something like :
    STRING(20) "A:1:{I:0;S:3:"174";}"

    Do you know how I could get each ID independently in a list (ul,li), and then use these ID’s to display specific information from each taxonomy it’s linked to (such as an image for example) ?

    Thanks 😉

  • Hi @abiwab

    Just to clarify, the var_dump was of the get_field value?

    The returned value should be an array, not a string…

  • Hi,
    Yes here is the code :

    <?php $values = get_field('animateurs_event');
    if($values)
    {
    echo '<ul>';
    foreach($values as $value){
    echo '<li>' . $value . '</li>';}
    echo '</ul>';
    }
    var_dump($values);	 
    ?>
  • Nevermind, I’ve found the solution. It was an error caused by the Events Plugin I’m using ! I finally got it to work 😉

    Thanks a lot !

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

The topic ‘Display list of taxonomy ID's and information linked to each ID’ is closed to new replies.