[wp-trac] [WordPress Trac] #20464: Page for Archives

WordPress Trac wp-trac at lists.automattic.com
Tue Apr 17 18:13:09 UTC 2012


#20464: Page for Archives
-----------------------------+------------------------------
 Reporter:  rabinbs          |       Owner:
     Type:  feature request  |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  General          |     Version:
 Severity:  normal           |  Resolution:
 Keywords:                   |
-----------------------------+------------------------------

Comment (by rabinbs):

 Yes this can be achieved by the '''category_templates''' but that is not
 the WordPress way.

 Here is how I'm doing this the WordPress way for now.

 I made a single post for every category and saved it as draft so that this
 page is not accessible anywhere else. Then pulling this post on the
 archive page '''category.php''' like /category/music/

 the code I'm using to pull it is


 {{{
 <?php
   $cat = get_query_var('cat');
   $args=array(
     'showposts' => 1,
     'category__in' => array($cat),
     'caller_get_posts'=>1,
     'post_status' => 'draft'
   );
   $posts=get_posts($args);
   if ($posts) {
     foreach($posts as $post) {
       setup_postdata($post); ?>
       <h1><a href="<?php the_permalink() ?>"><?php the_title();
 ?></a></h1>
       rest of the content
       <?php
     }
   }
 ?>

 }}}

 Now whenever a user visits the /category/music page it shows up the draft
 post and I can manage it the WordPress way.

 We have to wait untill some brilliant coder patches it and publish some
 real solution.

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


More information about the wp-trac mailing list