This members-only tutorial provides the steps to dynamically set the choices of a Select-type custom field created using Advanced Custom Fields plugin to all the public non-default post types in WordPress.
This will essentially let us set up our own Custom Post Type Selector field.
Note: Depending on your project needs, this may be an overkill and you could simply hardcode the CPT names in your desired order in the Select field. The purpose of this tutorial is not so much the final result but rather how it is done.
This code example can easily be applied to Select, Radio and Checkbox type of fields to populate them from any array.
Install and activate ACF (free or Pro).
Create your field group.
Leave the Choices blank.
Install and activate Code Snippets plugin.
Go to Snippets > Add New.
Title: Dynamically populate a custom field's choices with CPTs
This is a premium members-only content.
To view the rest of the content, please sign up for membership ($47/month or $599 one-time).
Already a member? Log in below or here.