Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am looking to create a page in Wordpress to output links to all of our posts from every month since we launched the blog. I have seen the archive.php template file in Wordpress, but this seems to overwrite a lot of other pages too (search results, author results, etc.)

So my plan is to create a single page similar to this archives page example. I was going to write a separate function solely for this page in my functions.php file, then use a shortcode to call out the info. Is this the best approach, or could I be going about this another way? Would appreciate any help on the topic :)

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I would suggest taking a look at the Template Hierarchy structure to fully understand WHY archive.php overwrites certain pages (although it shouldn't overwrite search results)

If you wanted to go a custom template direction (might be the best way) I would do something like this

create a monthly-arcive.php file and paste the following (you can name it whatever)

/**
 * Template Name: Monthly Archive
 */
  //get the header
 get_header();

//normal WordPress loop 
if ( have_posts() ) : while ( have_posts() ) : the_post(); 
    the_content();
endwhile; 
endif; ?>

//show the archive list
<?php wp_get_archives('type=monthly'); ?>

//get footer
<?php get_footer(); ?>

Then create a new page and select "Monthly Archive as its template and you should be all set.

Things to note: You will need to style the custom template to match your other pages you may even want to start out by making a copy of another page. You should also look at wp_get_archive() in the Codex for more examples.

Hopefully that helps.

share|improve this answer
    
yeah this was great I really appreciate your response! I think this is the best way to go about things. I'll pop back if I have problems but your example is practically dumb-proof –  Jake Rocheleau Sep 25 '11 at 21:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.