Home › Forums › General Issues › How to Add ACF to Categories?
Hello,
I have a custom taxonomy and I followed this tutorial to include a new ACF field when editing individual categories: http://naileditdesign.com/add-advanced-custom-field-category/
It works great, except when I view the main Categories page via WP Admin, I do not see my custom field in the category table. By default, it only shows Name, Description, Slug, and Count but I’d like the values for my custom category field to also appear in that table. How can I achieve this?
Also, for reference, here’s the code I’m working with. The second issue I’m running into is I’m not sure how to call the get_field value where it says “NEED-ACF-HERE”:
<?php // show all Video categories with posts
$custom_terms = get_terms('videos_categories',array('orderby'=>'NEED-ACF-HERE','order'=>'ASC'));
foreach($custom_terms as $custom_term) {
wp_reset_query();
$args = array('post_type' => 'videos',
'orderby' => 'date',
'posts_per_page' => 4,
'tax_query' => array(
array(
'taxonomy' => 'videos_categories',
'field' => 'slug',
'terms' => $custom_term->slug,
),
),
);
$loop = new WP_Query($args);
if($loop->have_posts()) {
?>
To add additional columns to the wp-admin category list, please take a look at this thread: http://wordpress.stackexchange.com/questions/6883/how-can-i-add-a-custom-column-to-the-manage-categories-table. Unfortunately, this is more od a WordPress question. Please consult to WordPress forum for further support.
I’m afraid there’s no easy way to sort terms based on a custom field. You need to use an advanced SQL query to do that or loop through the terms and sort it later. This page should give you more idea about it: https://support.advancedcustomfields.com/forums/topic/how-to-query-taxonomies-by-custom-field/.
Hope this helps.
The topic ‘How to Add ACF to Categories?’ is closed to new replies.
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.