Home › Forums › Feature Requests › Change the order of post types in Post Object field dropdown/search input › Reply To: Change the order of post types in Post Object field dropdown/search input
Short story: This isn’t possible.
ACF uses get_post_types() https://codex.wordpress.org/Function_Reference/get_post_types to get the list of available post types.
This function does not have any arguments to specify how they should be ordered. Basically WP just returns the contents of the global variable
$wp_post_types filtered to only show specific post types based on other arguments. The global value is an array of post types in the order that they are created.
I did some digging in WP and there isn’t any way to filter this that I can find.
Even when selecting the post types when creating the field, the same thing is done.
At some point before ACF accesses the post types, access the WP global variable and reorder the array of post types to the order you want them returned.
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 most recent ACF Chat Friday featured a live demo of how to register CPTs directly in the plugin, one of our most requested features. Check out the summary below for a replay of the demo, and don’t forget to register for the next session! https://t.co/k2KQ3WWBAz— Advanced Custom Fields (@wp_acf) March 9, 2023
© 2023 Advanced Custom Fields.