Home › Forums › General Issues › Use custom field of category in WP query › Reply To: Use custom field of category in WP query
Check out the documentation for get_field()
, specifically the section titled “Get a value from different objects”. You should be able to get the value from a field assigned to a category by passing the category ID as second parameter:
$color = get_field( 'my_field', $category[0]->cat_id );
…
echo($color);
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.