Open bradhogan opened 2 years ago
@bradley2083 Would you be able to share the code you're using to register the CPT?
If you're using a plugin for that, then maybe don't worry so much.
No problem @talldan here it is...
function mytheme_create_cpts() {
register_post_type( 'courses',
array(
'labels' => array(
'name' => __( 'Courses' ),
'singular_name' => __( 'Course' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'courses'),
'hierarchical' => true,
'show_in_rest' => true,
'menu_icon' => 'dashicons-screenoptions',
'supports' => array(
'thumbnail',
'editor',
'title',
'excerpt',
'author',
'page-attributes',
'custom-fields'
),
)
);
register_taxonomy(
'coursecategories',
'courses',
array(
'hierarchical' => true,
'label' => 'Categories',
'query_var' => true,
'show_in_rest' => true,
'rewrite' => array(
'slug' => 'coursecategories',
'with_front' => false
)
)
);
flush_rewrite_rules();
}
add_action( 'init', 'mytheme_create_cpts' );
Thanks, I'll give this a test a little later.
I gave it a test, and I see what's happening. As you mention you can add individual courses. The search system doesn't really support searching for a single custom post type, the same as searching for 'post' doesn't only show posts.
Something I'd recommend doing is adding item_link
and item_link_description
labels to your CPT. When you do that there will be a block variation for courses available in the main block library (here I've called it Course Link):
Adding that variation of the block will limit the search to just courses. It's not the easiest system though, it's still a bit hard to insert blocks into the navigation block using the main block library as you need to have another Link block selected.
I think there needs to be a better way to filter the search results when adding a link normally.
Thanks for taking a look. The old menu system had a clear way to choose a post types archive page for a menu. It seems odd this isn’t included at the moment. It almost seems like there needs to be a way to create placeholder pages like you would for “shop” if using Woo or “blog” for a posts front page for CPTs so the page wouldn’t have any content functionality but would then populate when searching “cpt_archive_name” etc.
On Wed, Mar 23, 2022 at 11:40 PM Daniel Richards @.***> wrote:
I gave it a test, and I see what's happening. As you mention you can add individual courses. The search system doesn't really support searching for a single custom post type, the same as searching for 'post' doesn't only show posts.
Something I'd recommend doing is adding item_link and item_link_description labels to your CPT. When you do that there will be a block variation for courses available in the main block library (here I've called it Course Link): [image: Screen Shot 2022-03-24 at 1 36 13 pm] https://user-images.githubusercontent.com/677833/159849593-6b25b57b-ff10-4980-9bc4-16b81ee50f15.png
Adding that variation of the block will limit the search to just courses. It's not the easiest system though, it's still a bit hard to insert blocks into the navigation block using the main block library as you need to have another Link block selected. I think there needs to be a better way to filter the search results.
— Reply to this email directly, view it on GitHub https://github.com/WordPress/gutenberg/issues/39644#issuecomment-1077220586, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANS32RWB4KM6WJLETX4I43VBP543ANCNFSM5RLMB4UQ . You are receiving this because you were mentioned.Message ID: @.***>
I see, sorry, for some reason I missed that it was the archive page you were looking for. Re-reading now, you did mention it, so my mistake 🤦
That is indeed something you can't do from the search. The only option is to add is as a a custom link.
I'll relabel this as an enhancement request as that might be worth supporting.
Custom post types are a cornerstone of WP. I'd be baffled if its not worth supporting.
Let me add here for your test, that adding it as a custom link breaks the 'is-current-page' 'is-current-menu-page' markers. (they don't display when for example you linked a custom post type archive, and you are in the archive), it also doesn't work for 'any' custom link entered in the menu.
They deprecated the customized navigation area, which would allow the use of the legacy menu manager and proposed the navigation block that loses the ability to add CPT's, which, as already mentioned, is the foundation of WP.
I sincerely hope that Wordpress continues to evolve, but a block that still doesn't cover the basic capabilities of the Legacy Menu Manager is making it difficult.
The way will be to create a template for the CPT archives. With that it will appear in the insertion of menus?
I’m sure they will get it right. Navigation is one of the most important aspects of a website..
But right now we’re either forced to used it as is, or drop the FSE (baby with the bathwater). That is why I proposed this: #39857
They deprecated the customized navigation area, which would allow the use of the legacy menu manager and proposed the navigation block that loses the ability to add CPT's, which, as already mentioned, is the foundation of WP.
The ability to add CPTs isn't lost. You can still add CPTs.
Currently there isn't a way to add the CPT Archive in the way the old menu system supported, and that's what's being discussed here.
Please do make a seperate issue if you're having problems with links to individual CPTs.
Hi, This issue has gone 180 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps. Thanks for helping out.
bump
This issue was reviewed in today's Editor Bug Scrub. We have been able to replicate using the latest versions of Gutenberg and WordPress.
+1 on this one, definately needed. just have to build custom links now for this.
Have the same issue, need a fix
Description
I have a "Courses" CPT and I'm unable to add this to a navigation block when simply search for "courses" as you can if you say want to add a Blog link (assuming that is your posts front page).
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes