Skip to content

Expand the types of templates that can be added in the Site Editor #37407

Closed

Description

@jameskoster

Currently it's possible to add the following Primary templates in the Site Editor:

  • Front page
  • Single
  • Page
  • Archive
  • Search
  • 404
  • Index

It's a good start, but the WordPress template hierarchy allows for much more expression. It would be good to explore flows that allow the creation of:

Author templates

  • author
  • author-$nicename

Category templates

  • category
  • category-$slug

Custom post type templates

  • single-$post-type
  • single-$posttype-$slug
  • archive-$posttype

Taxonomy templates

  • taxonomy
  • taxonomy-$taxonomy
  • taxonomy-$taxonomy-$term

Tag templates

  • tag
  • tag-$slug

Tangentially related:

Activity

  1. added
    [Type] Enhancement
    Needs Design
    [Type] Tracking Issue
    [Feature] Site Editor
    on Dec 15, 2021
  2. Otto42 commented on Dec 15, 2021

    @Otto42
    Member

    This would seem to be a necessary item for a viable release.

    The very first thing I attempted to do when switching to the new theme and editor was to try to find how to create a Category Archive template. Couldn't find it.

    Eventually I worked out that copying archive.html to category.html in twentytwentytwo did the trick, but that is very unintuitive.

    Seems like the existing Template Hierarchy should be used for defaults like this, and then expose all/most templates in that hierarchy as selections to be made. If I select "Category" for the template, but there's no category.html, it falls back to archive.html in the hierarchy, and that is my starting point for customization. But the customized template I then create is still the Category template, not the Archive template.

  3. karmatosed commented on Dec 17, 2021

    @karmatosed
    Member

    I really like the idea of expanding, but I wonder if that then needs easier ordering or something that doesn't surface everything at the same level? I worry a little about too long a list for example and problems even finding things. Something to explore!

  4. jameskoster commented on Dec 17, 2021

    @jameskoster
    ContributorAuthor

    For sure, this is not a trivial project!

    I'm also wondering if we'll see some overlap with #36667. If / when it is possible to work on a specific post category in the site editor, it seems plausible that we'd offer a way to spawn a new template for that category as a part of the overall flow.

  5. jameskoster commented on Dec 17, 2021

    @jameskoster
    ContributorAuthor

    The very first thing I attempted to do when switching to the new theme and editor was to try to find how to create a Category Archive template.

    Adding the secondary category template as an option for folks to create would obviously be a simple change we could make any time.

    Seems like the existing Template Hierarchy should be used for defaults like this, and then expose all/most templates in that hierarchy as selections to be made. If I select "Category" for the template, but there's no category.html, it falls back to archive.html in the hierarchy, and that is my starting point for customization.

    I think what you're describing is being worked on here.

  6. SJGraboski commented on Jan 4, 2022

    @SJGraboski

    Saw that this issue mentioned the possibility of creating custom post type templates in the Site Editor. Like several other web developers, I help manage a WP Multisite implementation. If the Site Editor allowed devs like us to make CPT templates, it would make for a profound improvement to our experience with WordPress.

    For starters, we could remove several child themes that exist only to provide our departments with CPT layouts, archives, and search pages. The only files we would need are the plugins that define the CPTs. Who wouldn't love a less complicated repo?

    The advantages stretch past the dev team. In theory, we could offer our editors the ability to edit these CPT templates, no coding required. This would enable our non-programming co-workers to change template layouts without relying on our assistance. The editors get more power over their sites, and the developers gain more hours of productivity.

    tl;dr, custom post type template creation through FSE would lend editors more freedom to change the site, while reducing the number of theme files developers would need to maintain.

  7. jameskoster commented on Jan 5, 2022

    @jameskoster
    ContributorAuthor

    Custom Post Type templates are an interesting one, because it brings in to question the creation of the CPTs themselves.

    Creating templates for existing CPTs feels like table stakes, but also a fairly developer oriented solution because it requires the CPT to be registered in the first place.

    Thinking further along the road... I wonder if there's a world where the Site Editor could enable users to add modules like "Portfolio" or "Testimonials". These modules could register the CPT and create all the necessary templates in a single flow. This would eliminate both the child theme and the plugin dependency from your example. With block patterns and other tools available to us we could potentially make this quite a compelling experience.

  8. aurooba commented on Jan 26, 2022

    @aurooba
    Member

    @jameskoster I enjoy the idea that core might provide a UI for CPT creation, sometimes I want a CPT, but don't want to have to pull out the code editor to do it, especially if it's going to have pretty much the same capabilities as a post.

    I'd also like to mention that as the ability to make more templates (and variations) comes into play, the ability to duplicate a customized template (and in the flow of doing so, assign the customizations to a different template) will be very very useful – I made an issue for that recently, #38192 (edit: I've closed the issue and added my comments to another existing issue #36665).

  9. jameskoster commented on Feb 8, 2022

    @jameskoster
    ContributorAuthor

    I spent some time exploring how we might expand the existing UI to accomodate other template types. There are a few different ways to organise things here, particularly around how we present singular / archive templates, and dynamic / static templates as well.

    What I felt worked well was separating templates by their specificity. That is to say: templates that serve a static purpose (404, front-page, *-$slug etc) are grouped together, and templates with a dynamic purpose appear beneath:

    Screenshot 2022-02-08 at 09 59 16

    It is important to note that while the list looks quite daunting, it is unlikely an end user would ever see it in its entirety like this because any template supplied by the theme would be omitted.

    This arrangement elevates the prominence of creating templates for a specific context – which I think is likely to be quite a popular flow – while still making it very simple to add common templates like page. Here's a video demonstrating how the "Specific template" menu item drills into a search form where I can find entity capable of entertaining its own template:

    template1.mp4

    Note that those blue boxes that appear on hover are template previews. Once #37258 lands I hope it will be possible to display a reasonable preview.

    The "Advanced" section at the bottom of the menu would contain templates that the average user is unlikely to use all that often, e.g. taxonomy. It may be prudent to put other less commonly used templates (like date) in here as well, and consider a different name for the section.

    Another thing I considered was splitting the dynamic section by singular / archive like so:

    Screenshot 2022-02-08 at 11 34 35

    But in the end it felt unnecessary.

  10. added
    Needs Design Feedback
    on Feb 8, 2022
  11. anelllya commented on Feb 10, 2022

    @anelllya

    What I don't quite understand is the need to perform a SEARCH once you want to go to a specific template. A search always implies that you know the name or that you know what you are looking for.
    I would show a list of probably the most used or last created templates with possibly a filter if users have too many.

    Other than that I find it a great idea to sort the templates that way.

  12. paaljoachim commented on Feb 10, 2022

    @paaljoachim
    Contributor

    Hey James! This is a very nice exploration!

    I find it helpful to separate templates into static and dynamic as in your suggestion.
    Clicking for instance "Specific template" and getting a search form. I would become lost not knowing what to search for. As I do not get a hint of options to choose from. Here I would need some additional guidance on how to proceed after selecting "Specific template".

    Having static and likely "most used" dynamic templates available is helpful. A see additional template choices - see additional templates > link to open another list can also be helpful.

    Kinda like this:
    Static template 1
    Static template 2
    Static template 3
    -- separater --
    Dynamic template 1
    Dynamic template 2
    Dynamic template 3
    Dynamic template 4
    Dynamic template 5
    Dynamic template 6
    -- separater
    See additional templates > (opens the Additional templates list)

    Btw previewing various templates would be nice.

  13. 20 remaining items

  14. moved this from Triage to In Progress in WordPress 6.0 Editor Taskson Mar 29, 2022
  15. moved this from In Progress to Triage in WordPress 6.0 Editor Taskson Mar 29, 2022
  16. getdave commented on May 5, 2022

    @getdave
    Contributor

    Merchants would need to completely rebuild the taxonomy template from scratch every time they wanted to create a variation for each product category.

    This is currently quite a jarring experience when you create a Category template. When we have the category-$slug.html functionality in the UI it would be ideal if the created template automatically used the block's from it's parent in the template hierarchy.

  17. mtias commented on May 9, 2022

    @mtias
    Member

    @getdave that's what #37258 aims for!

  18. jameskoster commented on May 16, 2022

    @jameskoster
    ContributorAuthor

    Here's a couple of design options focussed on the process of creating templates that can be generic or specific. In this case creating category or category-recipes.

    Option A

    This one builds off the last concept but simplifies the UI down to just a radio list.

    category-a.mp4

    Option B

    This one uses a two step process with more verbose descriptions.

    category-b.mp4
  19. mtias commented on May 19, 2022

    @mtias
    Member

    Option B looks like a good path to explore. I miss the extra helpful text we had here:

    image

    But tailored for what it means to add a template for a specific category slug, in this case.

  20. ntsekouras commented on May 19, 2022

    @ntsekouras
    Contributor

    Option B looks like a good path to explore. I miss the extra helpful text we had here:

    I'll start exploring this, but with post types for start. We can always iterate on the POC I'll have soon and I guess the approach taken will be similar for taxonomies, etc..

    @mtias you screenshot is a bit different from @jameskoster 's one. Is it more about the missing description?

    My first thoughts for postType would be a new menu item (if eligible) that would say Post Type and have two options:

    1. The generic one that is single template
    2. Select a custom one (that would show the available post types like single-post, single-project, etc...)
  21. jameskoster commented on May 19, 2022

    @jameskoster
    ContributorAuthor

    Is it more about the missing description?

    Yes I think so, we can add this in the PR.

    My first thoughts for postType would be a new menu item (if eligible) that would say Post Type and have two options:

    1. The generic one that is single template
    2. Select a custom one (that would show the available post types like single-post, single-project, etc...)

    To implement the design above consistently we'd have separate items per post type, and per taxonomy. As an example, if you had 'Products' as a CPT and 'Product categories' as a custom taxonomy then the add template menu would include:

    • Single product
    • Product archive
    • Product category

    Clicking "Single product" would ask if you want to add single-product or single-product-$slug using the "Option B" flow. Clicking "Product archive" would create archive-product. Clicking "Product category" would ask if you want to add taxonomy-product_cat or taxonomy-product_cat-$slug, again using the flow in Option B.

  22. jorgefilipecosta commented on Jul 4, 2022

    @jorgefilipecosta
    Member

    Working on author-$nicename.

  23. jorgefilipecosta commented on Jul 5, 2022

    @jorgefilipecosta
    Member

    author-$nicename ready for review at #37407.

  24. ntsekouras commented on Aug 25, 2022

    @ntsekouras
    Contributor

    All listed items have been merged.

  25. Repository owner moved this from Triage to Done in WordPress 6.0 Editor Taskson Aug 25, 2022
  26. locked as spam and limited conversation to collaborators on Nov 18, 2022
  27. Mamaduka commented on Nov 18, 2022

    @Mamaduka
    Member

    I locked the conversations on this issue. Unfortunately, the last few comments look like spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs DesignNeeds Design Feedback[Feature] Site Editor[Type] Enhancement[Type] Tracking Issue

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions