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


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

    • abiwab

    • August 28, 2013 at 10:22 pm

    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 😉

    • Elliot

    • August 29, 2013 at 2:28 pm

    Hi @abiwab

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

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

    • abiwab

    • August 29, 2013 at 6:06 pm

    Yes here is the code :

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

    • August 29, 2013 at 11:37 pm

    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)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.