Support

Account

Home Forums ACF PRO Selecting a Taxonomy and Showing Custom Fields Associated to That Taxonomy

Solving

Selecting a Taxonomy and Showing Custom Fields Associated to That Taxonomy

    • gfreecd

    • October 8, 2020 at 5:27 am

    Hello,

    I’m using ACF on a post type and one of those fields is a Select field that selects a Custom Taxonomy (Speaker Name). I’m also using Custom Fields for that Taxonomy (Speaker Title, Speaker Bio, Speaker Headshot, etc.). How can I pull the Taxonomy Custom Fields when the Taxonomy is selected in the Post Type.

    For instance, if I select the Speaker Name “Jon Smith”, I would like to automatically pull all of Jon Smith’s info.

    This works for pulling the Speaker Name

    $speakname= get_field('speaker_name');
    <p><?php echo $title; ?></p>

    This doesn’t work for pulling the Speaker Bio

    $bio= get_field('speaker_bio');
    <p><?php echo $bio; ?></p>

    Any idea how to get this to work?

    Thanks in advance!

  • 
    // get tax field without formatting, returns term if
    $speakname= get_field('speaker_name', false, false);
    
    // get field from term
    $bio= get_field('speaker_bio', 'term_'.$speakname);
    

    https://www.advancedcustomfields.com/resources/adding-fields-taxonomy-term/

    • gfreecd

    • October 8, 2020 at 9:13 am

    Hmm, so the code I provided works when I’m viewing that taxonomy archive (i.e. http://www.example.com/speakers/) but when I view a post type archive (i.e. http://www.example.com/category/) it doesn’t work.

    I do have the Field Group set to show when that Taxonomy is set to Speakers… so how do I get them to display the values on other category/archive pages?

Viewing 3 posts - 1 through 3 (of 3 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.