i don’t have the same approach, it should be an acf function not a wp function.
ACF should give a function to output $field[‘choices’] regardless of where it is used and regardless of if it is used or not.
if the plugin can export a field, we should be able to get the raw field structure with an acf function, outside of the post scope 🙂
thanks i’ll try that!
anyway it would be cool to be able to do that with an acf function like
get_field_object( 'field_name', $post_id = false );
If the post id is false, it should return the field object without having to pass a real post id as an argument.
@elliot if you read this…
yes that’s it.
Because I have an option to sort by post type in my search form, i would like to be able to search for all post OR just certain post types.
if possible i don’t want to make a wp query just to get the field options, i want to get the field options like on the export tools on acf admin page (i don’t care about all that, but it is just an example of sorting the field structure without a $post->ID) :
if( function_exists(‘acf_add_local_field_group’) ):
acf_add_local_field_group(array ( 'key' => 'group_55ba39c6cc9d7', 'title' => 'Langues', 'fields' => array ( array ( 'key' => 'field_55ba39cd8bb11', 'label' => 'Langue', 'name' => 'langue', 'type' => 'select', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array ( 'width' => '', 'class' => '', 'id' => '', ), 'choices' => array ( 'francais' => 'Français', 'anglais' => 'Anglais', 'espagnol' => 'Espagnol', 'allemand' => 'Allemand', 'portugais' => 'Portugais', 'russe' => 'Russe', 'arabe' => 'Arabe', 'chinois' => 'Chinois', 'hindi' => 'Hindi', 'japonais' => 'Japonais', 'autre' => 'Autre', ), 'default_value' => array ( 'francais' => 'francais', ), 'allow_null' => 1, 'multiple' => 0, 'ui' => 0, 'ajax' => 0, 'placeholder' => '', 'disabled' => 0, 'readonly' => 0, ), ), 'location' => array ( array ( array ( 'param' => 'post_type', 'operator' => '==', 'value' => 'document', ), ), ), 'menu_order' => 1, 'position' => 'acf_after_title', 'style' => 'default', 'label_placement' => 'top', 'instruction_placement' => 'label', 'hide_on_screen' => '', 'active' => 1, 'description' => '', )); endif;
outside of the search result loop, i have the search form like this :
Sort by :
– post type
the languages choices must sort all the languages select option on the field ‘language’. That is what i want 🙂
because i am not on a post that is using this field (i am on the search page), i cannot use
to sort all options available for ‘language’ field.
get_field_object(‘language’) returns false because i am not on the scope of that field (this field is for posts not for pages).
I want something to get the field structure regardless of the post id.
Something like the export of acf fields, but with a function i can use on my theme/plugin
language field is only for some custom post types, but if i must put it on all post types, i could do it.
I just want to output all available select options that are part of this field (french, english, chinese, spanish, etc…), regardless of posts in search results.
I just want to show the field choices on a page (the custom field is not assigned to the search page so i cannot use get_field_object(‘language’, $post->ID) ).
And this bug is also for displaying the field on admin post-edit page.
It duplicate the content (see this picture : http://i59.tinypic.com/t7hp2t.png) and put the first block on p class=”description” tag.
Same problem for me since the last update (acf pro).
We are 4 now guys 🙂
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!
ACF wouldn’t be so widely used in WordPress if it didn’t have some pretty amazing capabilities. In this article, we look at a few of the features we’ll discuss during “7 things you didn’t know you could do with ACF” at #WPEDecode later this month. https://t.co/5lnsTxp81j pic.twitter.com/Yf0ThPG1QG— Advanced Custom Fields (@wp_acf) March 16, 2023
© 2023 Advanced Custom Fields.