Home Forums ACF PRO Custom Post Type Selection Question


Custom Post Type Selection Question

  • Hi Elliot! (or helpful staff member)

    I love ACF, my clients love ACF, and now I’m using ACF5 and I love it too!

    One minor drawback I’ve noticed…
    Before ACF5, there was a neat plugin called acf-post-type-selector (developed by someone else), which allowed me to retrieve a post type and run custom queries in the code.

    This plugin is not compatible with ACF5, and while ACF5 does indeed have a post object (which only selects individual posts), and a relationship field (which will allow me to select multiple posts from a post type). I am still unable to provide an ACF solution for my client to choose a dynamic pull (like the 5 most recent) of a custom post type of their choosing.

    Do you have any neat solutions that I seem to be missing here? Or should I go ahead and try to hack the acf-post-type-selector to work with ACF5?

    Thanks for all your hard work in the battle against hardcoding.

    P.S. I love you. Seriously. Like whoa. I can’t even…

  • Hi Galen,

    Did you manage to find a solution for this?


  • I made a V5 fork for that plugin,
    probably it will be merged back into the original,
    for now you can find it here:

  • +1 for this feature.

  • Hi Galen et. al

    Aint ACF a treat 🙂 Been using it myself since it’s very early days.

    While I do see the reason why you could use this kind of field I don’t think it’s broadly needed enough to be considered as a core field. It does however sound like a great add on! And since @playid has actually forked the original add on to work with ACF 5 I would recommend you to just go ahead with that!

    It’s hard to turn down field ideas for core but I think that ACF is better of with not too specialized fieldtypes for the broader masses. With the ease of creating new add ons (especially with ACF5) there’s no reason not to just create an add on of our own when needed. Just remember to name it properly and perhaps give a shout here on the forum and it might end up on the add ons page:

  • Hi everyone. I’ve just worked in a solution for this issue thanks to a reply from James on a different question. I’ve created a set of custom fields on an options page where my user can create a custom header/footer to appear before/after a post type and had manually created a list of post types for them to choose from. This wasn’t great as the list would include assumed and potentially unused post types (like ‘product’) and not include post types added by plugins beyond my control.

    I now hijack that select field and populate it with only active (and ‘public) post types with the following function:

    function acf_load_post_type_choices( $field ) {

    $field[‘choices’] = array();
    $choices = get_post_types( array(‘public’ => true) );

    if( is_array($choices) ) {
    foreach( $choices as $choice ) {
    $field[‘choices’][ $choice ] = $choice;
    return $field;

    add_filter(‘acf/load_field/name=post_types’, ‘acf_load_post_type_choices’);

    Hope someone finds that useful.

  • @galenu4eastudios-com

    If you find any of these posts satisfying it’d be great if you could set one as the solution so this topic is considered done 🙂

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

The topic ‘Custom Post Type Selection Question’ is closed to new replies.