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

WordPress Trac wp-trac at lists.automattic.com
Mon Sep 24 17:05:23 UTC 2012


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

 * status:  closed => reopened
 * resolution:  wontfix =>


Comment:

 I think, that both ways are wrong - i would choose more files, because
 when developer opens the file, it has just few rows, each exactly for that
 particular job.

 But i think, we should consider IMO third sollution. We have so huge/many
 files because 2 simple needs

 1. show title. Why the hell we need so huge function to show just the
 title?!?! Look at this:

 {{{
 <?php
 if ( is_day() ) {
         printf( __( 'Daily Archives: %s', 'twentytwelve' ), '<span>' .
 get_the_date() . '</span>' );
 } elseif ( is_month() ) {
         printf( __( 'Monthly Archives: %s', 'twentytwelve' ), '<span>' .
 get_the_date( _x( 'F Y', 'monthly archives date format', 'twentytwelve' )
 ) . '</span>' );
 } elseif ( is_year() ) {
         printf( __( 'Yearly Archives: %s', 'twentytwelve' ), '<span>' .
 get_the_date( _x( 'Y', 'yearly archives date format', 'twentytwelve' ) ) .
 '</span>' );
 } elseif ( is_tag() ) {
         printf( __( 'Tag Archives: %s', 'twentytwelve' ), '<span>' .
 single_tag_title( '', false ) . '</span>' );
 } elseif ( is_category() ) {
         printf( __( 'Category Archives: %s', 'twentytwelve' ), '<span>' .
 single_cat_title( '', false ) . '</span>' );
 } else {
         _e( 'Blog Archives', 'twentytwelve' );
 }
 ?>
 }}}
 (and it still miss the post_type_archive_title or any other title, which
 may be needed in archive.php (search???)

 Why we simple do not have something like the_archive_title() and
 get_archive_title(), which would contain this complex function in it and
 return always the proper title. Translations of the context can be easily
 done from standard .pot, and/or the function could have some optional
 parameters, where you can define sprintf format form for each term ...
 array('day'=>Daily Archives: %s', 'month'=>'Monthly Archives: %s'...). And
 when someone would need something special, the output would be filtered so
 he can use filter, or he can always replace it with today's function.

 The second complexity is very similar, but not for title, but for
 description.

 So if we would put to wordpress those two simple function, we could stay
 with only one very easy-to-read and short archive file, which would fit
 needs for 99,9% developers. At it would be also future proof as when we
 will need to add anything else to archive, we just update this function

 This is how the header part of header.php would look and we will save 30
 rows (or 5 diferent files)

 {{{
 <header class="archive-header">
 <h1 class="archive-title"><?php the_archive_title() ?></h1>

 <div class="archive-meta"><?php the_archive_description ?></div>

 </header><!-- .archive-header -->
 }}}

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


More information about the wp-trac mailing list