Advertisement
alchymyth

archive,php

Jun 17th, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3.  * @package WordPress
  4.  * @subpackage Starters
  5.  */
  6.  
  7. get_header();
  8. ?>
  9.  
  10. <div id='page'>
  11.  
  12. <?php if (have_posts()) : ?>
  13.  
  14. <div id='posts'>
  15.  
  16. <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
  17. <?php /* If this is a category archive */ if (is_category()) { ?>
  18. <h2>Archive for the &#8216;<?php single_cat_title(); ?>&#8217; Category</h2>
  19. <?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
  20. <h2>Posts Tagged &#8216;<?php single_tag_title(); ?>&#8217;</h2>
  21. <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
  22. <h2>Archive for <?php the_time('F jS, Y'); ?></h2>
  23. <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
  24. <h2>Archive for <?php the_time('F, Y'); ?></h2>
  25. <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
  26. <h2>Archive for <?php the_time('Y'); ?></h2>
  27. <?php /* If this is an author archive */ } elseif (is_author()) { ?>
  28. <h2>Author Archive</h2>
  29. <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
  30. <h2>Blog Archives</h2>
  31. <?php } ?>
  32.  
  33. <?php next_posts_link('&laquo; Older Entries') ?> | <?php previous_posts_link('Newer Entries &raquo;') ?>
  34.  
  35. <?php while (have_posts()) : the_post(); ?>
  36.  
  37.     <div class='prepost'>
  38.         <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  39.             <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
  40.             <p class='postdate'>Written by <?php the_author() ?> on <?php the_time('F jS, Y') ?></p>
  41.             <?php the_content('<br />Read the rest of this entry &raquo;'); ?>
  42.             <p class='postnotes'>Filed under <?php the_category(', ') ?><?php the_tags(' | Tags: ', ', ', '<br />'); ?></p>
  43.             <br />
  44.         </div><!--/ .post-ID -->
  45.         <div class='postpost'></div>
  46.     </div><!--/ .prepost -->
  47.    
  48. </div><!-- THIS SHOULD NOT BE HERE IN THE LOOP -->
  49.  
  50. <?php endwhile; ?>
  51.  
  52. <?php else :
  53.  
  54. if ( is_category() ) { // If this is a category archive
  55.     printf("<h2>Sorry, but there aren't any posts in the %s category yet.</h2>", single_cat_title('',false));
  56. } else if ( is_date() ) { // If this is a date archive
  57.     echo("<h2>Sorry, but there aren't any posts with this date.</h2>");
  58. } else if ( is_author() ) { // If this is a category archive
  59.     $userdata = get_userdatabylogin(get_query_var('author_name'));
  60.     printf("<h2>Sorry, but there aren't any posts by %s yet.</h2>", $userdata->display_name);
  61. } else {
  62.     echo("<h2>No posts found.</h2>");
  63. }
  64. get_search_form();
  65.  
  66. endif;
  67. ?>
  68.  
  69. <!-- THE CLOSING DIV SHOULD PROBABLY BE HERE, SEE BELOW THIS LINE -->
  70. </div><!--/ .posts -->
  71.  
  72.  
  73. <?php get_sidebar(); ?>
  74.  
  75. </div>
  76.  
  77. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement