Home › Forums › Add-ons › Repeater Field › Fill up repeater fields with category › Reply To: Fill up repeater fields with category
Hi !
Firstly, thanks for your answer, this allow me to move up a bit !
But i’m still stuck there, here is my code before that i tried to integrate your answer
function my_load_cat($value, $post_id, $field){
$args = array( 'parent' => 779 );
$post_categories = wp_get_post_terms( get_the_ID(), 'category', array("fields" => "ids") );
if ( !empty( $post_categories ) ) {
$args['exclude'] = $post_categories;
};
$categories = get_categories( $args );
Firstly i’ve created a function, and inside of it i ask wp to load only the category that are not belonging to the current post, and that they have the parent’s id as “779”
foreach ( $categories as $category ) {
$value[]=array(
'field_5cd186302ef1c' => $category->name
);
};
return $value;
};
And then i grab all those terms that i placed in a foreach loop, in order to have all of them inside of my repeater field
}
add_filter('acf/load_value/name=villes_a_ajouter_III', 'my_load_cat', 10, 3);
And at last i apply the filter that i want, in order to load all of them.
But this keep adding me some new row once i clicked on update the post, this is quite a bite a problem
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!
🚨 The 2023 ACF Annual Survey closes tomorrow! This is your last chance to complete the survey and help guide the evolution of ACF. https://t.co/0cgr9ZFOJ5
— Advanced Custom Fields (@wp_acf) May 18, 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.