Open stotzbalazs opened 1 day ago
To make post types available via REST API, you need to set the show_in_rest
param to true
. The endpoint doesn't check the publicly_queryable
value.
The getPostTypes
selector just makes requests to the REST API endpoints; it doesn't do separate filtering.
Yes, but my problem is exactly related to this: the post types available via REST API, the show_in_rest
param is set to true
.
However, the code snippet above only shows the given post type if it is set to publicly_queryable
.
@stotzbalazs, can you share a post-type registration snippet for reproduction? I can't reproduce it locally using my test post types.
I use ACF for post type creation, so it looks like this:
add_action( 'init', function() {
register_post_type( 'committee', array(
'labels' => array(
'name' => 'Committees',
'singular_name' => 'Committee',
'menu_name' => 'Committee',
'all_items' => 'All Committee',
'edit_item' => 'Edit Committee',
'view_item' => 'View Committee',
'view_items' => 'View Committee',
'add_new_item' => 'Add New Committee',
'add_new' => 'Add New Committee',
'new_item' => 'New Committee',
'parent_item_colon' => 'Parent Committee:',
'search_items' => 'Search Committee',
'not_found' => 'No committee found',
'not_found_in_trash' => 'No committee found in Trash',
'archives' => 'Committee Archives',
'attributes' => 'Committee Attributes',
'insert_into_item' => 'Insert into committee',
'uploaded_to_this_item' => 'Uploaded to this committee',
'filter_items_list' => 'Filter committee list',
'filter_by_date' => 'Filter committee by date',
'items_list_navigation' => 'Committee list navigation',
'items_list' => 'Committee list',
'item_published' => 'Committee published.',
'item_published_privately' => 'Committee published privately.',
'item_reverted_to_draft' => 'Committee reverted to draft.',
'item_scheduled' => 'Committee scheduled.',
'item_updated' => 'Committee updated.',
'item_link' => 'Committee Link',
'item_link_description' => 'A link to a committee.',
),
'public' => true,
'publicly_queryable' => false,
'show_in_rest' => true,
'menu_icon' => 'dashicons-businessman',
'supports' => array(
0 => 'title',
1 => 'thumbnail',
2 => 'custom-fields',
),
'taxonomies' => array(
0 => 'committee-type',
1 => 'local-network',
),
'delete_with_user' => false,
) );
} );
@stotzbalazs, I get the same results. The "Committees" post type is returned by the selector.
Description
For some reason WordPress requires to have Publicly Queryable for post types to populate them in Editor. Why is this necessary? In many cases, post types that are not Publicly Queryable are not visible in the editor and cannot be used.
Is it possible to enable all post types without relating on Queryable?
Step-by-step reproduction instructions
I'm using
to get post types and that way i'm unable to populate post types in editor which are not "Publicly Queryable"
Screenshots, screen recording, code snippet
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.