Home › Forums › Backend Issues (wp-admin) › Add column in backend with ACF
Hi,
I want to know if it’s possible to filter in backend for a ACF.
I have a CPT products with his ACF restaurant type Post Object to relation with the other CPT restaurants (working like a charm in frontend :p), It could be nice to filter in backend for ACF restaurant in CPT product.
Maybe add a column like (title, language, autor, data, restaurant) or something like that, to make it easy for the admin users, or add a select with list of restaurants to filter the products of this restaurant.
It’s easy to do?
I have a filter in backend
function my_acf_result_query( $args, $field, $post )
{
if ($args['field_key'] == 'field_517165b44fc90') {
$args['meta_query'] = array(
array(
'key' => 'restaurant',
'value' => get_field('restaurant', $args['post_id'])->ID,
'compare' => '='
)
);
}
return $args;
}
add_filter('acf/fields/relationship/query', 'my_acf_result_query', 10, 2);
but I don’t know if I can use the same. I’m quite new in WP and I don’t know wich utilities there are for the backend.
Some help or information could be fantastic. 🙂
Thanks a lot!
Hi @jimmy.aat10
In general, yes, it is possible to filter the posts shown in an ACF field.
This said, I’m quite confused as to what fields you are using.
Is the field a post object or relationship?
Also, where would you want to add a column? TO what interface? Perhaps use a screenshot to demonstrate
Hi,
in the post view in backend.
I add a screenshot.
Because there are a long list of products, it could be practic to see the restaurant of this product or filter for a particular restaurant.
The product has a ACF type Post Object restaurant that is assigned in every product with his description, image, price, discount, etc.
Thanks!
Hi @jimmy.aat10
Check out a plugin called ‘codepress admin columns’
http://www.advancedcustomfields.com/resources/getting-started/compatible-plugins/
@jimmy.aat10: How did you solve it? I would love to know. The plugin Elliot suggested is too expensive – I don’t need anything fancy, and I’m not afraid to code. You apparently got it working on your own.
The topic ‘Add column in backend with ACF’ 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’re reaching out to our multilingual users to ask for help in translating ACF 6.1. Help make sure the latest features are available in your language here: https://t.co/TkEc2Exd6U
— Advanced Custom Fields (@wp_acf) May 22, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.