Post Types Selector
A dropdown that lists registered public WordPress post types. Useful in settings or option pages where editors configure which post types a feature applies to — search indexes, feed exports, archive layouts, and similar.
Pro field
Post Types Selector requires the Extra Fields for ACF Pro license.
Settings
| Setting | Default | Options | Description |
|---|---|---|---|
| Multiple | false | on/off | Allow selecting more than one post type. |
| Include Built-in | true | on/off | Include WordPress core types (post, page, attachment). |
| Exclude | (empty) | Comma-separated slugs | Post type slugs to hide from the dropdown, e.g. attachment,revision. |
| Return Format | slug | slug · label · object | What get_field() returns for each selection. |
Return values
Single select
$pt = get_field('search_post_type');
// return_format: 'slug'
// "product"
// return_format: 'label'
// "Product"
// return_format: 'object'
// WP_Post_Type object — access $pt->name, $pt->label, etc.
Multi-select
Returns an array of values in the chosen format.
$types = get_field('feed_post_types');
// ['post', 'product', 'event'] (return_format: 'slug')
Usage
Dynamic WP_Query using the selected type
$post_type = get_field('featured_post_type', 'option'); // from options page
if ($post_type) {
$posts = get_posts([
'post_type' => $post_type,
'posts_per_page' => 6,
]);
}
Multi-select: loop across post types
$types = get_field('index_post_types', 'option'); // return_format: 'slug', multiple
if ($types) {
$all_posts = get_posts([
'post_type' => $types,
'posts_per_page' => -1,
'fields' => 'ids',
]);
}
Feeding into a REST API endpoint
$type = get_field('api_post_type', 'option');
if ($type) {
$url = rest_url('wp/v2/' . $type);
$response = wp_remote_get($url);
}
Validating a submitted post type
$selected = get_field('search_scope'); // slug
$valid = get_post_types(['public' => true]);
if (in_array($selected, $valid, true)) {
// Safe to use in a query
}