doakcode

Archive.php

Jun 17th, 2012
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.25 KB | None | 0 0
  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>
  45.         <div class='postpost'></div>
  46.     </div>
  47.    
  48. </div>
  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. <?php get_sidebar(); ?>
  70.  
  71. </div>
  72.  
  73. <?php get_footer(); ?>
  74.  
  75.  
  76. #CSS
  77.  
  78. /* =========== Page/Post Stuff ======== */
  79. #posts {
  80.     float: left;
  81.     width: 620px;
  82. }
  83.  
  84. .prepost {
  85.     background: transparent url(images/post-head.png) 50% 0 no-repeat;
  86.     padding-top: 14px;
  87.     margin: 20px auto;
  88.     width: 620px;
  89.     float: left;
  90. }
  91.  
  92. .post {
  93.     background: transparent url(images/opaque-bg.png) 0 0 repeat;
  94. }
  95.  
  96. .post h2 {
  97.     padding-bottom: 0;
  98. }
  99.  
  100. .postpost {
  101.     width: 100%;
  102.     height: 14px;
  103.     background: transparent url(images/post-foot.png) 50% 100% no-repeat;
  104. }
  105.  
  106. .postdate {
  107.     color: #666;
  108.     padding: 6px 20px;
  109.     font-style: italic;
  110.     font-size: .9em;
  111. }
  112.  
  113. .postnotes {
  114.     padding: 20px 6px 20px 20px;
  115.     font-size: .9em;
  116. }
Advertisement
Add Comment
Please, Sign In to add comment