Support

Account

Home Forums General Issues Problem adding ACF to Taxonomy Page

Solved

Problem adding ACF to Taxonomy Page

  • Hi,

    I’ve been struggling with this for days and Googled this to death! πŸ™

    Apologies in advance, if this is a really simple question.

    Basically, I’m trying to add two ACF text values to a Taxonomy (Tag) page.

    One is for the link value (page_link) and one is for the name of the link (page_name)

    I’ve set up ACF so I’m able to add both these values on the Edit Tag (Taxonomy) page in WordPress

    In my tag.php page I have the following line of code:

    <a href="<?php bloginfo('url'); ?>/<?php the_field('page_link'); ?>"><?php the_field('page_name'); ?></a>

    I hoped it would load the page_link and page_name values into this code.

    When I view the page source in the browser, none of the ACF values are coming through?

    I’ve managed to get ACF working on category, page, and posts – but for some reason, it doesn’t seem to work on Taxonomy / Tag pages?

    I’m wondering if either this isn’t possible, or I need to add an extra step in the page code?

    Or my ACF settings are incorrect:

    In ACF for both fields, Location is set to: Taxonomy – is equal to – All

    Both fields are active, set to Text, and published.

    I hope someone can help, thanks in advance, kind regards

    Brian

  • You need to supply the term. See Adding fields to a taxonomy

    
    $queried_object = get_queried_object(); 
    ?>
    <a href="<?php bloginfo('url'); ?>/<?php the_field('page_link', $queried_object); ?>"><?php the_field('page_name', $queried_object); ?></a>
    
  • Hi John, you are an absolute Star! – thank you so much πŸ™‚ – that sorted it. I had almost given up hope. Thanks again for your help, kindest regards Brian

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

You must be logged in to reply to this topic.