Support

Account

Home Forums Feature Requests Change the order of post types in Post Object field dropdown/search input

Helping

Change the order of post types in Post Object field dropdown/search input

  • I’m regularly using the post object field to create relationships to other posts on the site.

    At the moment, the default “posts” post type is the first that is displayed in the list, ahead of ‘pages’ and other custom post types. Usually when creating post object relationships, it will be to a page or to a custom post type. It’s rare that I’ll be selecting the default post type, which will generally be used for blog posts.

    The problem I’m experiencing is that on larger sites it’s time consuming to scroll past the many blog posts to find the page or custom post I need, even when adding a search term (as quite often there will be many blog posts containing the name of the page/custom post I’m looking for)

    I think it would be an improvement to have the pages & custom posts listed before the standard post type in the dropdown.

  • Short story: This isn’t possible.

    Long story:

    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.

    Possible Hack:
    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.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Change the order of post types in Post Object field dropdown/search input’ is closed to new replies.