[wp-trac] [WordPress Trac] #21951: Twenty Twelve: add post_type_archive_title to archive.php

WordPress Trac wp-trac at lists.automattic.com
Wed Sep 26 19:30:32 UTC 2012


#21951: Twenty Twelve: add post_type_archive_title to archive.php
---------------------------+-----------------------
 Reporter:  thomask        |       Owner:
     Type:  enhancement    |      Status:  reopened
 Priority:  normal         |   Milestone:  3.5
Component:  Bundled Theme  |     Version:
 Severity:  normal         |  Resolution:
 Keywords:  has-patch      |
---------------------------+-----------------------

Comment (by mdgl):

 My humble opinions are as follows (agreeing largely with thomask and
 knutsp):

 a) A single "archive.php" rather than multiple templates for each archive
 type seems like the best compromise for an exemplar theme such as Twenty-
 Twelve. At one extreme, the template hierarchy means you could do
 everything within a single "index.php" but this would be rather
 complicated with much conditional code, etc. At the other extreme,
 utilising the hierarchy in full (e.g. including all attachment media
 types, author, tag, category, taxonomy, custom post type, ...) would
 result in too much duplication of code. A balance/compromise is therefore
 needed! In general, I think that archives are displayed in the same way
 with just the exception of the page title (and "not found" text) so this
 points to the use of a single generic template file. Changes appropriate
 to just a single content type are probably best left to child themes and
 use of the specialised template files.

 b) Although custom post types are an extension to WP, I believe the
 exemplar theme should at least allow them to be viewed in some generic
 fashion via "archive.php" and "single.php". For practical purposes, you
 probably want to define custom post types in a plugin rather than a theme,
 because at least then your content remains viewable and editable in the
 admin tool, even when you switch themes. Yes, theme support will likely be
 required for almost all custom post types, but at least handling them to
 some extent makes the exemplar theme useful to child theme developers.

 c) As thomask points out, the code in Twenty-Twelve's "archive.php" (and
 similarly in many other themes) is rather messy and much of this behaviour
 should be provided by core functions (e.g. see #21995). In fact, in my own
 theme I have further generalised those functions to cope with the header
 and description elements for other pages such as search and home. You end
 up with three separate core template tags for a page's title (wp_title()),
 page header and page description which can be applied everywhere. The
 challenge is to make these easily customisable where necessary :-) As I
 have commented elsewhere, this all points to the fact that the interface
 between WP core and themes (the "Theme API" if you will) is getting a
 little bit messy and could do with some love and attention (or
 "hardening") in 3.6. Just look at all of the outstanding tickets we have
 with basic functionality such as wp_title() and the_content()! And think
 of how many hours of effort are needed by the army of plugin/theme
 developers to check their fragile dependencies against core and update
 their workarounds on each new WP release!!

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21951#comment:32>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list