Open webmandesign opened 10 months ago
A problem with editing the slug for template parts is that it breaks the connection to any template part block that references it. In order to make slug changes a reality any instance of template parts every instance of a template part would also need to be updated. That is possible, though I'm not sure that it's on a roadmap.
I think it has some relation to this issue - Reusable blocks and Template Parts isolated editing view: Add menu in top toolbar for navigating to usage locations, since both require being able to search across a site for template part usage.
Template parts also use the slug to maintain a connection to the theme provided template part (for the customization and 'clear customizations' feature), so that's another area that would need some thought.
I'm not sure if there are any similar constraints for templates.
@talldan Thanks for the valuable feedback.
Indeed, this would cause issues. User would need to take this in consideration when editing the slug then. But I may be biased as I am a theme developer, so I am OK with it, though I understand it can cause confusion for users that don't understand why their template part references stopped working suddenly. Maybe a description/note for such slug edit option would do here?
Alternatively, could a slug edit option be available when define( 'WP_DEVELOPMENT_MODE', 'theme/all' );
is defined in wp-config.php
file? It would be beneficial when theme developers build their theme in Site Editor.
As for the theme provided template parts issue: I would only like to edit the slug when creating a custom, user-defined template part, not when editing the theme one. I think this is doable as themes define their template parts via theme.json
file (or they are recognized as a files in theme's parts
folder), so WordPress already knows the difference - which template part is the theme one and which is the user/custom one.
Interesting suggestions.
It could also be in the scope for a plugin like Create Block Theme if it's primarily for theme builders. Have you used that before?
There's an issue tracker here for that plugin.
What do you think?
I've used the Create Block Theme plugin before, but I no longer use it. I prefer to build my theme in code editor and then test and do finishing steps in Site Editor. That's when I came across the need described in this issue.
But I'm not against the toggle option for this in the plugin, so I'll check it out. Thanks.
What problem does this address?
When creating a user/custom Template Part or Template in Site Editor, it seems I am not able to set up custom slug for these.
Usecase:
post_type
query parameter is set. But it displayssearch-jetpack-portfolio.html
template whenpost_type
parameter is defined (and set withjetpack-portfolio
value) in search.If I use WordPress in English, I can live with setting up "Search Jetpack Portfolio" title/name for my custom created Template for displaying search results for
jetpack-portfolio
post type, although it is not ideal solution. The "Search Jetpack Portfolio" producessearch-jetpack-portfolio
slug for the Template, so the theme recognizes it and applies my custom template when Jetpack Portfolio post type is being searched.But if I use WordPress in different language, the slug is produced from the title I type in in such language and it is different than theme required
search-jetpack-portfolio
slug.Currently there seems to be no way for me to adapt my custom template slug.
query-sidebar
slug to it (possibly just due to my OCD :) ).What is your proposed solution?
It would be great if there was some option field to edit slug for Template Part and Template post type. Something like: