Advertisement
Guest User

Untitled

a guest
Mar 21st, 2012
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. // change cat=25 to the category ID you want
  2. // get the first post date in cat 25
  3. $lastdate = get_posts('posts_per_page=1&cat=25&order=ASC');
  4. list($end_date, $time) = explode(' ', $lastdate[0]->post_date);
  5. $lastdate = strtotime ( $end_date);
  6.  
  7. $today = strtotime ( date('Y-m-j'));
  8. if(isset($_GET['newsdate']) && $_GET['newsdate']){
  9. $today_page = strtotime ($_GET['newsdate']);
  10. $yesterday = strtotime ( '-1 day' , $today_page ) ;
  11. $tommorow = strtotime ( '+1 day' , $today_page );
  12. list($year,$month,$day) = explode('-', $_GET['newsdate']);
  13. } else {
  14. $yesterday = strtotime ( '-1 day' , $today) ;
  15. $tommorow = strtotime ( '+1 day' , $today);
  16. list($year,$month,$day) = explode('-', date('Y-m-j'));
  17. }
  18.  
  19. query_posts('year='.$year.'&monthnum='.$month.'&day='.$day.'&cat=25');
  20.  
  21. if($yesterday > $lastdate) {
  22. echo '<a href="' . get_permalink() . '?newsdate='. date ( 'Y-m-j',$yesterday).'">previous day link</a>';
  23. }
  24.  
  25. if($tommorow < $today) {
  26. echo '<a href="' . get_permalink() . '?newsdate='. date ( 'Y-m-j',$tommorow).'">next day link</a>';
  27. }
  28.  
  29. if($tommorow == $today) {
  30. echo '<a href="' . get_permalink() . '">next day link</a>';
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement