Make WordPress Core

Opened 9 years ago

Last modified 8 years ago

#35326 new enhancement

New taxonomy template

Reported by: sebastianpisula's profile sebastian.pisula Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: has-patch needs-refresh dev-feedback
Focuses: template Cc:

Description

I sugest neww taxonomy template: taxonomy-{$term->term_id}.php.

taxonomy-$taxonomy-{$term->slug}.php is bad because if I change slug then I must remember about change filename. In my website this isn't problem but if client change name on website then will be problem.

Attachments (1)

35326.patch (571 bytes) - added by sebastian.pisula 9 years ago.

Download all attachments as: .zip

Change History (8)

#1 follow-up: @swissspidy
9 years ago

  • Component changed from Themes to Taxonomy
  • Focuses template added
  • Keywords has-patch needs-refresh added
  • Milestone changed from Awaiting Review to Future Release

category-{$category->term_id}.php and tag-{$tag->term_id}.php exist as well, but after the slug variant.

So adding taxonomy-$taxonomy-{$term->term_id}.php seems legit (not taxonomy-{$term->term_id}.php)

Example:

$templates[] = "taxonomy-$taxonomy-{$term->slug}.php"; 
$templates[] = "taxonomy-$taxonomy-{$term->term_id}.php"; 
Last edited 9 years ago by swissspidy (previous) (diff)

#3 in reply to: ↑ 1 @sebastian.pisula
9 years ago

WordPress 4.5.0 ? :)

Replying to swissspidy:

category-{$category->term_id}.php and tag-{$tag->term_id}.php exist as well, but after the slug variant.

So adding taxonomy-$taxonomy-{$term->term_id}.php seems legit (not taxonomy-{$term->term_id}.php)

Example:

$templates[] = "taxonomy-$taxonomy-{$term->slug}.php"; 
$templates[] = "taxonomy-$taxonomy-{$term->term_id}.php"; 

#4 follow-up: @theMikeD
9 years ago

@swissspidy since term IDs are now unique thanks to all the term splitting, why do we need $taxonomy in taxonomy-$taxonomy-{$term->term_id}.php?

#5 in reply to: ↑ 4 ; follow-up: @swissspidy
9 years ago

Replying to theMikeD:

@swissspidy since term IDs are now unique thanks to all the term splitting, why do we need $taxonomy in taxonomy-$taxonomy-{$term->term_id}.php?

I suggested it because of consistency.

First, there's already taxonomy-$taxonomy-{$term->slug}.php, so adding a template with the ID makes sense. Second, this helps developers figuring out what's going on. For example, taxonomy-123.phpsounds like it's the template for a taxonomy with the ID 123. taxonomy-color-123.php is more obvious.

Finally, when the taxonomy name can be left out, term-123.php would make more sense. But again, this would not be consistent with the existing templates..

#6 in reply to: ↑ 5 @theMikeD
9 years ago

Replying to swissspidy:

Replying to theMikeD:

@swissspidy since term IDs are now unique thanks to all the term splitting, why do we need $taxonomy in taxonomy-$taxonomy-{$term->term_id}.php?

I suggested it because of consistency.

First, there's already taxonomy-$taxonomy-{$term->slug}.php, so adding a template with the ID makes sense.

In the case of a slug it's needed because two terms in different taxonomies can have the same slug. This isn't true for IDs.

Second, this helps developers figuring out what's going on. For example, taxonomy-123.phpsounds like it's the template for a taxonomy with the ID 123. taxonomy-color-123.php is more obvious.

This is in direct opposition to how term splitting is being done, specifically how the taxonomy field is being stripped from term functions. Why the inconsistency? IMHO I think it's fair to expect developers to read the template docs to determine how they work without needing this type of hand holding.

Finally, when the taxonomy name can be left out, term-123.php would make more sense. But again, this would not be consistent with the existing templates.

If clarity is the goal, consider what we already have:
category-{$category->term_id}.php
tag-{$tag->term_id}.php

Using taxonomy-{$term->term_id}.php or $taxonomy-{$term->term_id}.php is more consistant with the category and tag template names than taxonomy-$taxonomy-{$term->term_id}.php

If consistency is the goal, IMHO you have two choices:
category-{$category->term_id}.php
tag-{$tag->term_id}.php
$taxonomy-{$term->term_id}.php
or
taxonomy-category-{$category->term_id}.php
taxonomy-tag-{$tag->term_id}.php
taxonomy-$taxonomy-{$term->term_id}.php

Or we can use term-{$term->term_id}.php, have it called after category-{$category->term_id}.php, tag-{$tag->term_id}.php in the hierarchy, and not only is this issue solved but we can look forward to eventually phasing out the category- and tag-specific templates and simplifying the hierarchy. All thanks to term splitting.

#7 @swissspidy
8 years ago

  • Keywords dev-feedback added
Note: See TracTickets for help on using tickets.