WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#20464 closed feature request (wontfix)

Page for Archives

Reported by: rabinbs Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords: close
Focuses: Cc:

Description

Using WordPress as a CMS requires this feature where we can set a "page" as a "homepage" for an archive(like category or tags).
Say we have a category named music and when people visit "/category/music" they should see a page created for this category instead of list of posts.
This should be an optional feature and if no page is set for an archive then the user gets traditional list of posts.
A plugin named cat2page was doing this but it is completely dead now and there is no other patch for this.

Change History (7)

comment:1 @ocean903 years ago

You should create a template for your category archive, see http://codex.wordpress.org/Category_Templates.

comment:2 @Ipstenu3 years ago

You could adjust your theme and use category-music.php as your custom page. True, it's not editable by WP, but that's the normal way to make a 'custom category archive page.'

The example here is pretty much it, though it uses category-ID.php and not category-SLUG.php:
http://codex.wordpress.org/Template_Hierarchy#Examples

comment:3 @rabinbs3 years ago

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.

comment:4 @rabinbs3 years ago

Can somebody please improve this code so that it can conditionally check if there is any draft post for this category or not? If there is a draft post then show it otherwise the traditional category archive.

comment:5 @ocean903 years ago

  • Keywords close added

Templates are one the main features of WordPress, it's "the WordPress way".

To get help you should try the support forum: http://wordpress.org/support/

comment:6 @greenshady3 years ago

Just create a custom category.php. Then, display the category description for your category "content".

comment:7 @SergeyBiryukov3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.