- This topic has 7 replies, 3 voices, and was last updated 3 years, 3 months ago by
David.
-
AuthorPosts
-
July 16, 2022 at 5:44 am #2284314
Jan
Hi David,
we created a custom post type and embedded the post type via a custom plugin.
Now would like to embed a query loop that picks the 3 latest items from the custom post type. Unfortunately, I don’t get to choose the custom post type from the blocks settings.
Any idea on what I may be missing?
Thanks,
JanJuly 16, 2022 at 6:27 am #2284342David
StaffCustomer SupportHi there,
you need to make sure the CPT supports the Rest API for it to display in the editor:
ie. in your CPT args it should include
'show_in_rest' => true,July 16, 2022 at 8:27 am #2284569Jan
Hi David,
this did the trick ;-).
Thanks for this helping hand! I greatly appreciate that.
Best,
JanJuly 17, 2022 at 5:29 am #2285099David
StaffCustomer SupportYou’re welcome
January 12, 2023 at 1:04 am #2492461Thierry
Hi David,
Sorry for reopening this, but I’ve set up my CPT with show_in_rest => true, still it doesn’t show in the “Select post type” dropdown.
Here’s how I registered the post type :
$labels = array( 'name' => __( 'Occasions', TEXT_DOMAIN ), 'singular_name' => __( 'Occasion', TEXT_DOMAIN ) ); $args = array( 'label' => __( 'Occasions', TEXT_DOMAIN ), 'labels' => $labels, 'supports' => array( 'title', 'thumbnail' ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'show_in_admin_bar' => true, 'menu_position' => 35, 'menu_icon' => 'dashicons-hammer', 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'publicly_queryable' => false, 'capability_type' => 'post', 'show_in_rest' => true, ); register_post_type( 'occasions', $args );I tried flushing_rewrite_rules via code and refreshing the page, but it doesn’t work. Maybe there’s another setting here preventing my CPT from showing ?
Thanks !
January 12, 2023 at 3:49 am #2492630David
StaffCustomer SupportHi there,
i believe you also need to set:
'publicly_queryable' => true,January 12, 2023 at 5:37 am #2492717Thierry
Hi David,
Thanks for the quick fix, it works !
January 12, 2023 at 8:40 am #2493091David
StaffCustomer SupportGlad to hear that!
-
AuthorPosts
- You must be logged in to reply to this topic.