Support

Account

Home Forums General Issues Retrieve Custom Taxonomy Field Value in Custom Tax & Post Type

Solved

Retrieve Custom Taxonomy Field Value in Custom Tax & Post Type

  • Hi there,

    Stumped… worked for a different theme / app, but for whatever reason, guessing I am missing something ‘simple’, I cannot retrieve the value of a checkbox (or any other ACF field) for custom taxonomy for custom post type (and I can retrieve default fields like term_description().

    get_terms();
    Loop w/ foreach (print_r just fine / correctly);
    Assign $variables ‘->’ (echos just fine)

    So:

    
    $term_id = $term->term_id;
    $term_tax = $term->taxonomy;
    
    $test_desc = get_field( 'custom_desc', $term_tax . '_', $term_id );
    

    Nothing. Drivn me coo coo. 🙂

    And, cannot get value of checkbox (or any other test term) for term, as seen above with ‘custom_desc’ field.

    Any help would be GREATLY appreciated, as I have lost a day of production messing with this so far. Ya… waaaahhh. 😉

    Thanks in advance!

  • You have a small mistake in the function parameters.
    Just replace the comma with a dot.
    Should be like this:
    $test_desc = get_field( ‘custom_desc’, $term_tax . ‘_’ . $term_id );
    or
    $test_desc = get_field( ‘custom_desc’, ‘term_’ . $term_id );

    Here is the doc:
    https://www.advancedcustomfields.com/resources/adding-fields-taxonomy-term/

  • OMG! Thank you… I feel like a klutz now!

    Wow…

    I soooo appreciate you pointing that out. Perhaps I need to copy paste more, as I checked the last instance I made, as mentioned, and it was a period! HELLO! Jeepers!

    Thanks, Aregmk, you made my day! 🙂

  • You’re welcome!

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

You must be logged in to reply to this topic.