Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template Hierarchy: Extend to include root taxonomy archives #7989

Draft
wants to merge 37 commits into
base: trunk
Choose a base branch
from

Conversation

ockham
Copy link
Contributor

@ockham ockham commented Dec 10, 2024

WIP. Based on #7271. More details to follow.

Nomenclature

For a given taxonomy projects that has terms such as film or tv:

  1. The root taxonomy route is /projects.
  2. Non-root taxonomy routes are any routes that include not only the taxonomy but also any of the taxonomy's terms, e.g. /projects/film or /projects/tv.

What

WordPress currently only supports non-root taxonomy routes. They are handled by this part of the template hierarchy:

image

(With an eventual fallback to archive.html and finally index.html, not depicted above.)

In #7271, I'm proposing a new flag to register_taxonomy() that will allow WordPress to support root taxonomy routes for a given taxonomy; however, that PR doesn't make any changes to the template hierarchy -- instead falling back to the generic archive template (archive.html).

This PR proposes to extend the template hierarchy to include a dedicated template for root taxonomy routes.

How

As discussed in #13816, there are two major options for what a root taxonomy archive should display:

  1. A list of all the taxonomy’s terms (i.e. /projects shows a list of items called TV, Films, etc, but not the individual posts that have those terms assigned).
  2. A list of all posts that have any of the taxonomy’s terms assigned (i.e. /projects shows a list of all posts that have either tv or film or any other term from the projects taxonomy assigned).

While 1. is somewhat more consistent with the existing (non-root) taxonomy templates, a majority of people in #13816 seem to have been in favor of 2. My own use case would be a template that can be shared by both non-root and root taxonomy routes.

I thus believe that we should accommodate for both options.

AFAICS, this is best done by introducing two new templates for the root taxonomy archives that take precedence, and eventually fall back to the (non-root) taxonomy templates, like so:

image

Trac ticket:


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@ockham ockham self-assigned this Dec 10, 2024
@ockham ockham changed the title Add/tax query for all terms in taxonomy extend template hierarchy Template Hierarchy: Extend to include root taxonomy archives Dec 10, 2024
@ockham ockham force-pushed the add/tax-query-for-all-terms-in-taxonomy-extend-template-hierarchy branch from 66a05a8 to 41cf11d Compare December 10, 2024 19:34
Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant