Closed AlexVWeb closed 4 years ago
Please make your issue more informative. I don't understand your problem.
Also, try registering your fields with the UI and see if that works first.
With the code below, I want to recover the "Sport" taxonomy in "Object" format, the problem is that I receive at the output only the ID, while the same form done with the administration of ACF works.
register_extended_field_group([
'title' => 'Sport',
'location' => [
Location::if('taxonomy', 'championship')
],
'fields' => [
Taxonomy::make('Sport', 'sport')
->returnFormat('object')
->taxonomy('sport')
->loadTerms()
->saveTerms()
->createTerms()
->appearance('select'),
],
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => PARAMS['hide_all_screen'],
'description' => '',
]);
dump(get_field('sport', $match['championship']));
I get the ID: When I should get a WP_Term:
I have the same problem with several other "Fields", but on another project everything worked fine!
(Translated from French)
Does it work if you register your fields with the UI instead of this package?
Does it work if you register your fields with the UI instead of this package?
Yes it works very well with the UI interface, this problem also happens to me with the Repeaters, when I do a
get_field('repeater', $ post_id)
on a Repeater Wordplate it returns the ID, whereas with the UI interface it returns the content of the elements of my repeater
Okay, then it could be an issue with this package. Have you looked into the source code and see if you could find the issue?
What is the output of following code in your project? We need to confirm that we get the correct field data.
$field = Taxonomy::make('Sport', 'sport')
->returnFormat('object')
->taxonomy('sport')
->loadTerms()
->saveTerms()
->createTerms()
->appearance('select');
dump($field->toArray());
Just tried this locally and it seems to work if you remove loadTerms
.
Predictable behavior
I should have a table with my different fields included in my repeater.
Actual behavior
I get the number of elements to create when I dump:
dump ($match, get_field ('site', $match-> ID));
I take back" 1 "
instead of retrieving with the same fields generate in the ACF administration:
0 => [ "url" => [ "title" => "Home" "url" => "// localhost: 3000 /" "target" => "" ] "logo" => [] ]
Steps to reproduce the problem
I can't reproduce the bug
Versions