---
description: >-
  https://support.advancedcustomfields.com/forums/topic/get-custom-taxonomy-field-value/
---

# Get Custom Taxonomy Field Value, acf, advanced custom fields (ok)

<figure><img src="https://2370029328-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LWPtKFbhw0XehxVuoiZ%2Fuploads%2FDhGNgc8vxxcdmZcyaFcz%2Fimage.png?alt=media&#x26;token=af88143b-873c-4c0f-9a63-02163c868c22" alt=""><figcaption></figcaption></figure>

```php
$gallery = get_field('gallery', 'category_414');
echo '<pre>';
var_export($gallery);
echo '</pre>';
```

## Get Custom Taxonomy Field Value

*   ![](https://secure.gravatar.com/avatar/22555420b58622edbfa2f20cff2ff0ab?s=64\&d=mm\&r=g)

    * #### [MACscr](https://support.advancedcustomfields.com/forums/users/macscr/)
    * [July 9, 2013 at 3:57 pm](https://support.advancedcustomfields.com/forums/topic/get-custom-taxonomy-field-value/#post-334)

    I have a custom Taxonomy term named ‘Campus’. I then have a custom field within that term called ‘Address’. Any suggestions on how I should best return the Address when I have the value of Campus? Im hoping to avoid a dirty sql query, then having to cache it myself so that i dont have to make a special query on each page load. This taxonomy is not related to a particular post. Nor should it need to be in my opinion. I asked this question earlier this year and I never figured it out, but since you changed forums, I cant just continue my last post or go back and check it out. =/

    *
*   ![](https://support.advancedcustomfields.com/wp-content/themes/acf-support/assets/images/badges/acf-guru.png)![](https://secure.gravatar.com/avatar/533079e82e526367047100d8019cb9a7?s=64\&d=mm\&r=g)

    * #### [Elliot](https://support.advancedcustomfields.com/forums/users/elliot/)
    * [July 10, 2013 at 2:57 pm](https://support.advancedcustomfields.com/forums/topic/get-custom-taxonomy-field-value/#post-466)

    Just to clarify, you are asking how do you load a custom field value from a taxonomy term when you know the taxonomy type and the term ID?

    Please read this documentation article:\
    [http://www.advancedcustomfields.com/resources/how-to/how-to-get-values-from-a-taxonomy-term/](http://www.advancedcustomfields.com/resources/how-to/how-to-get-values-from-a-taxonomy-term/)

    *
*   ![](https://secure.gravatar.com/avatar/3b0fe729fad3cda37cda51d4167145e4?s=64\&d=mm\&r=g)

    * #### [rapidz](https://support.advancedcustomfields.com/forums/users/rapidz/)
    * [September 17, 2013 at 5:11 pm](https://support.advancedcustomfields.com/forums/topic/get-custom-taxonomy-field-value/#post-4288)

    I’m having the same issues. I’m using WooCommerce, WPML and ACF. WooCommerce creates a custom taxonomy called ‘product\_cat’. The name of the field I’m trying to get is ‘Subscribe Field Name’.

    I’m using the following, but it’s not returning anything:\
    `<?php echo get_field('subscribe_field_name', 'product_cat_16');?>`

    It’s driving me crazy.

    *
*   ![](https://secure.gravatar.com/avatar/3b0fe729fad3cda37cda51d4167145e4?s=64\&d=mm\&r=g)

    * #### [rapidz](https://support.advancedcustomfields.com/forums/users/rapidz/)
    * [September 17, 2013 at 5:29 pm](https://support.advancedcustomfields.com/forums/topic/get-custom-taxonomy-field-value/#post-4290)

    Must’ve been something with the field name. I added a new field with the name cm\_id and it worked.

    *
*   ![](https://secure.gravatar.com/avatar/ae8079b1fbdd058017250ad134e42c65?s=64\&d=mm\&r=g)

    * #### [BLiN](https://support.advancedcustomfields.com/forums/users/blin/)
    * [December 19, 2013 at 12:27 am](https://support.advancedcustomfields.com/forums/topic/get-custom-taxonomy-field-value/#post-8901)

    It’s driving me crazy but I totaly don’t understand how I can get value from custom filed that is custom taxonomy term (select). I read “How to get values from a taxonomy term” 10 times. I search all the forum with words taxonomy custom field. I don’t understand where I can get value of $TermID?\
    \<p>\<?php the\_field(‘field\_name’, ‘category\_7’); ?>\</p>\
    – so tell me please where are you get that “7” ?\
    I have custom taxonomy called ‘my\_taxonomy’ (I use Custom Post Types UI plugin) and I have custom field (my\_field – select from taxonomy values list) in custom post (type my\_post\_type). So I want to post its value in frontend?\
    Will be appreciate if you colud give the examples or the link to docs or at least turn me to the right way.\
    1\) Get the taxonomy (one value – select or radiobutton) field value?\
    2\) Get the taxonomy (few values – checkboxes) field array of values?\
    3\) Get the repeater nested taxonomy field value?\
    Thanks in advance

    P.S. Sory for my bad english. May be that SQL clear what I want –

    ```php
    SELECT name
    FROM  wp_terms 
    WHERE term_id
    IN (

    SELECT term_id
    FROM  wp_term_taxonomy
    WHERE taxonomy =  'where_from'
    AND term_taxonomy_id
    IN (

    SELECT term_taxonomy_id
    FROM  wp_term_relationships
    WHERE object_id =418 //post_id
    )
    )
    ```

    but instead of ” taxonomy = ‘where\_from’ ” – value from unknown table that has relationship field\_name — taxonomy\_name

    *
*   ![](https://support.advancedcustomfields.com/wp-content/themes/acf-support/assets/images/badges/acf-guru.png)![](https://secure.gravatar.com/avatar/533079e82e526367047100d8019cb9a7?s=64\&d=mm\&r=g)

    * #### [Elliot](https://support.advancedcustomfields.com/forums/users/elliot/)
    * [December 19, 2013 at 10:02 am](https://support.advancedcustomfields.com/forums/topic/get-custom-taxonomy-field-value/#post-8921)

    Hi [@BLiN](https://support.advancedcustomfields.com/forums/users/blin/)

    You say that you have used a taxonomy field to select a taxonomy. Is this a single or multiple select field?

    To get the selected taxonomy term, you use the get\_field function like so:

    ```php
    $term = get_field('taxonomy_field_name')
    ```

    Then,make sure you have a return format setting of ‘Object’ instead of ‘ID’.

    You can then use $term to load data from the taxonomy term like so:

    ```php
    <?php 

    // load thumbnail for this taxonomy term
    $thumbnail = get_field('thumbnail', $term->taxonomy . '_' . $term->term_id);

    ?>
    ```

    Thanks\
    E

    *
*   ![](https://secure.gravatar.com/avatar/6cab36897d9bf2aa8d3f25e989e59db8?s=64\&d=mm\&r=g)

    * #### [thePixelPixie](https://support.advancedcustomfields.com/forums/users/brotsky_pixie/)
    * [August 14, 2016 at 5:48 am](https://support.advancedcustomfields.com/forums/topic/get-custom-taxonomy-field-value/#post-42140)

    I think my problem is similar to what’s been going on here, but I’m still coming up blank.

    I have a taxonomy field (checkbox, so multiple items can be chosen) inside a custom post type. So far so good. My query displays the selected taxonomies.

    But within those custom taxonomy terms I’ve added a FontAwesome field, so each term has an icon associated with it.

    What I’m trying to do is display all icons of terms selected within the custom post.

    Here’s my code so far (like I said, the term name itself is displaying just fine, but I want the icon associated with that term to be displaying):

    ```php
    <?php $terms = get_field('tech_choices');
    $cat_icon = get_field('creative_icon', $queried_object); ?>
    <span>
    	<?php if( $terms ): ?>
    	<ul>
    		<?php foreach( $terms as $term ): ?>
    		<li><a href="<?php echo get_term_link( $term ); ?>"><?php echo $term->name; ?></a></li>
    		<?php $icon = get_field('creative_icon', $term->taxonomy . '_' . $term->term_id); echo $icon; ?>
    		<?php endforeach; ?>
    	</ul>
    	<?php endif; ?>
    </span>
    ```

    *
*   ![](https://secure.gravatar.com/avatar/7a4c06345eca5902eaf9b253f205044f?s=64\&d=mm\&r=g)

    * #### [zethzethdk](https://support.advancedcustomfields.com/forums/users/zethzethdk/)
    * [June 5, 2019 at 9:09 pm](https://support.advancedcustomfields.com/forums/topic/get-custom-taxonomy-field-value/#post-91014)

    The link above ( [http://www.advancedcustomfields.com/resources/how-to/how-to-get-values-from-a-taxonomy-term/](http://www.advancedcustomfields.com/resources/how-to/how-to-get-values-from-a-taxonomy-term/) ) gives a 404. Based on the URL, I would really like to read that article (and I can’t find it, using Google). Any help?

    *
*   ![](https://support.advancedcustomfields.com/wp-content/themes/acf-support/assets/images/badges/acf-guru.png)![](https://secure.gravatar.com/avatar/533079e82e526367047100d8019cb9a7?s=64\&d=mm\&r=g)

    * #### [Elliot](https://support.advancedcustomfields.com/forums/users/elliot/)
    * [December 5, 2019 at 10:06 am](https://support.advancedcustomfields.com/forums/topic/get-custom-taxonomy-field-value/#post-125775)

    Hi [@zethzethdk](https://support.advancedcustomfields.com/forums/users/zethzethdk/). The article you are looking for is this one: Adding fields to a taxonomy term – [https://www.advancedcustomfields.com/resources/adding-fields-taxonomy-term/](https://www.advancedcustomfields.com/resources/adding-fields-taxonomy-term/)

    *
*   ![](https://secure.gravatar.com/avatar/16563e454a9bce4a66c82bedc014b7d5?s=64\&d=mm\&r=g)

    * #### [johnw6761](https://support.advancedcustomfields.com/forums/users/johnw6761/)
    * [February 5, 2021 at 6:10 am](https://support.advancedcustomfields.com/forums/topic/get-custom-taxonomy-field-value/#post-138755)

    This worked for me to get the taxonomy terms for the current post with an ACF icon field attached:

    ```php
    <?php $terms = get_the_terms( get_the_ID(), 'project_services' );
    $cat_icon = get_field('icon', $queried_object); 
    ?>

    <?php if( $terms ): ?>
    <ul class="menu">
    	<?php foreach( $terms as $term ): ?>
    	<li>
    		<a href="<?php echo get_term_link( $term ); ?>">
    			<?php $icon = get_field('icon', $term->taxonomy . '_' . $term->term_id);?>
    			<img src="<?php echo $icon ?>">
    			<?php echo $term->name; ?>
    		</a>
    	</li>
    	<?php endforeach; ?>
    </ul>
    <?php endif; ?>
    ```

    *

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

The topic ‘Get Custom Taxonomy Field Value’ is closed to new replies.
