Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. function acf_load_my_load_cat($value, $post_id, $field){
  2.  
  3. $args = array( 'taxonomy' => 'ville_formation');
  4. $post_categories = wp_get_post_terms( get_the_ID(), 'ville_formation', array("fields" => "ids") );
  5.  
  6.  
  7. if ( !empty( $post_categories ) ) {
  8. $args['exclude'] = $post_categories;
  9. };
  10.  
  11. $categories = get_terms( $args );
  12.  
  13. $value=array();
  14.  
  15. if (empty($value)) {
  16. // this repeater do not already has a value, change it
  17. foreach ( $categories as $category ) {
  18. $value [] = array(
  19. 'field_5cd186302ef1c' => $category->name);
  20. }
  21.  
  22. };
  23.  
  24. return $value;
  25. };
  26. add_filter('acf/load_value/name=villes_a_ajouter_III', 'acf_load_my_load_cat', 10, 3);
  27.  
  28. function acf_load_my_load_cat($value, $post_id, $field){
  29.  
  30. $args = array( 'taxonomy' => 'ville_formation');
  31. $post_categories = wp_get_post_terms( get_the_ID(), 'ville_formation', array("fields" => "ids") );
  32.  
  33.  
  34. if ( !empty( $post_categories ) ) {
  35. $args['exclude'] = $post_categories;
  36. };
  37.  
  38. $categories = get_terms( $args );
  39.  
  40. $value=array();
  41.  
  42. if (empty($value)) {
  43. // this repeater do not already has a value, change it
  44. foreach ( $categories as $category ) {
  45. $value [] = array(
  46. 'field_5cd186302ef1c' => $category->name);
  47. }
  48.  
  49. };
  50. return $value;
  51. };
  52. add_filter('acf/load_value/name=villes_a_ajouter_III', 'acf_load_my_load_cat', 10, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement