To be more accurate, here’s the content of the text widget :
[acf field="company"] – [acf field="address"], [acf field="zipcode"] [acf field="city"], [acf field="country"]
Yes it was a typo. The text is :
[acf field="company"]
The values are saved on the current post.
When I use elementor shortcode widget, the company displays ok. And the other fields also.
But when I try to display them using the shortcodes, it displays empty values.
Hello,
Thanks for your answer, I think it will be ok.
Just one question :
How get I get the field_key from the field_name ?
For example I do this :
$current_status = get_field('status', $post_id);
to retrieve the current value, beofre save.
But to get the posted value I have to first get the key of this “status” field.
Thanks
Regards
Hello,
Thanks but it’s not working…
I’m not able to get the actual value of the field, I just have the value updated…
Regards,
Finally I understood what was going on.
I used the debugger and saw that internally the function tries to get an ID.
And in my case, the ID was the page ID where the search engine is called.
So what i did is : I changed the function that’s supposed to retrieve the values from the select. First thing I do is that I get one item from my custom post types and I get its ID. This way when I do the “get_field_object” call then it’s not false anymore.
Thanks for your help.
That’s correct, I didn’t pass the value of the post because I don’t have any.
Let me explain you the module :
I created some custom posts which are “formation”.
Each formation post type has several custom fields that are handled by ACF, and “type de formation” is one of them.
When I created these custom fields, I added ome values, because these fields are select fields.
So they have several possible choices, as you already understood.
But the choices are independant from the is of the formation.
In my module I’m going to create a kind of search engine that will contain 2 selects : one of them will be “type de formation”. That’s why I need to retrieve all the possible values that were set in ACF.
So when a user chooses a “type de formation” in my search engine, then it will display all the “formations” of this type.
Do you understand better ?
So in my module i’m trying here to build the select.
That’s why I wanted to get the object “domaine_de_formation”, and in this case, all the possible choices.
Because let’s say tomorrow I add a new choice in ACF, I don’t want to have to edit my module, obviously.
I don’t know if I’m clear… sorry for my english, I’m french 🙂
Thanks for your help.
Regards
Exactly, I’m trying to get the values of the choices that I set when creating the field.
You say they are in ['choices']
but I don’t understand…
Actually, get_field_object( 'domaine_de_formation' )
returns false, and not any field settings.
Could you please be more specific about this ['choices']
variable or function ?
Thanks
hello ? Anybody could help me ?
I’m really stuck with this thing…
Hello, anyone to help me ?
I’m very stuck…
Thanks
Hello Maru,
I finally developed it myself.
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.