Advertisement
alchymyth

all posts per day

Mar 5th, 2011
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.37 KB | None | 0 0
  1. <?php
  2. /*
  3. Template Name: Day Posts
  4. author: alchymyth
  5. web: transformationpowertools.com
  6.  
  7. formatting based on 'kubrick default'
  8. */
  9.  
  10. get_header();
  11. ?>
  12.  
  13. <?php get_sidebar('left'); ?>
  14.  
  15.  
  16.     <div id="content" class="narrowcolumn">
  17.    
  18. <?php $all_dates = get_posts('numberposts=-1');
  19. foreach($all_dates as $all_date) { $date_list[] = get_the_time('Y m d', $all_date->ID); }
  20. $datelist = array_unique($date_list);
  21. $datelist = array_values($datelist);
  22. $pagelink = get_permalink();
  23. ?> 
  24. <?php //$nr = 1;
  25. //foreach($datelist as $date_set) {
  26. //echo '<a href="' . $pagelink . '/page/'. $nr . '">' . $date_set . '</a><br/>'; $nr++; }  
  27. ?>
  28.  
  29. <?php
  30. $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // pagination
  31. echo '<h3>Showing Posts of '; echo $dates = $datelist[$paged-1]; echo '</h3>';
  32. $dates = explode(' ', $dates);
  33. $this_year = $dates[0];
  34. $this_month = $dates[1];
  35. $this_day = $dates[2];
  36.  
  37. $args = array(
  38. 'year' => $this_year,
  39. 'monthnum' => $this_month,
  40. 'day' => $this_day,
  41. 'posts_per_page' => -1, // optional to overwrite the dashboard setting
  42. 'orderby' => 'date',
  43. 'order' => desc
  44. );
  45. query_posts($args);
  46. ?>
  47.  
  48. <?php if (have_posts()) :
  49.  
  50.     while (have_posts()) : the_post(); ?>
  51.    
  52. <!-- core post area -->
  53. <div id="post-<?php the_ID(); ?>" class="posting">
  54.         <div <?php post_class() ?> >
  55.             <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php echo get_post_meta($post->ID,'incr_number',true).' - '; ?><?php the_title(); ?></a></h2>         
  56.             <div class="entry">    
  57.                    
  58.                 <?php the_excerpt(''); ?>
  59.  
  60.                 <?php the_tags( '<p>Tags: ', ', ', '</p>');  ?>    
  61.                        
  62.             </div>
  63.            
  64.         </div>
  65.         </div>
  66. <!-- end of core post ares --> 
  67.          
  68.     <?php endwhile; ?>
  69.  
  70.     <div class="navigation">
  71.     <?php  $last_paged = count($datelist); ?>
  72.         <div class="alignleft"><?php if($paged >= 2) { echo '<a href="' . $pagelink . '/page/'. ($paged-1) . '">next day - ' . $datelist[$paged-2] . '</a>'; } else { echo 'no newer day'; } ?></div>
  73.         <div class="alignright"><?php if($paged < $last_paged) { echo '<a href="' . $pagelink . '/page/'. ($paged+1) . '">previous day - ' . $datelist[$paged] . '</a>'; } else { echo 'no earlier day'; } ?></div>
  74.     </div>
  75.    
  76. <?php   else: ?>
  77.  
  78.         <p>Sorry, no posts matched your criteria.</p>
  79. <?php endif;
  80. wp_reset_query(); ?>
  81.  
  82. </div>
  83. <?php get_sidebar(); ?>
  84.  
  85. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement