Home Forums General Issues It is possible to select a custom post type via ACF?


It is possible to select a custom post type via ACF?

  • Lets say, I have some different custom-post-types: movies, directors, cinemas…

    is it somehow possible to select a custom-post-type via an acf-field?

    I want to build an url to a specific cpt-archive using wordpress function get_post_type_archive_link()

    I tried the Page-Link functionality. But I think it delivers flat urls. And I need to filter them.


  • You can create a post type selection field by using a select field and then dynamically populating that select field using what is returned by get_post_types() and get_post_type_object().

  • Any code example?

    It is not well understood, there are not even example images in that documentation

    They should add that functionality instead of waiting for the user to program it, there have been questions for 10 years looking for that functionality

  • It would be impossible to create a solution that fit everybody’s needs. So they provide a way to do anything you want thanks to the acf/load_field/name=$name filter, which is even better.

    The documentation John shared does give examples.
    From the first section (Populating Choices From a Text Area Field), the author of this thread would basically just need to replace $choices = get_field('my_select_values', 'option', false); with $choices = get_post_types(); and also remove the two next lines that trim the string as it is already an array of name.

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

You must be logged in to reply to this topic.