Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // change cat=25 to the category ID you want
- // get the first post date in cat 25
- $lastdate = get_posts('posts_per_page=1&cat=25&order=ASC');
- list($end_date, $time) = explode(' ', $lastdate[0]->post_date);
- $lastdate = strtotime ( $end_date);
- $today = strtotime ( date('Y-m-j'));
- if(isset($_GET['newsdate']) && $_GET['newsdate']){
- $today_page = strtotime ($_GET['newsdate']);
- $yesterday = strtotime ( '-1 day' , $today_page ) ;
- $tommorow = strtotime ( '+1 day' , $today_page );
- list($year,$month,$day) = explode('-', $_GET['newsdate']);
- } else {
- $yesterday = strtotime ( '-1 day' , $today) ;
- $tommorow = strtotime ( '+1 day' , $today);
- list($year,$month,$day) = explode('-', date('Y-m-j'));
- }
- query_posts('year='.$year.'&monthnum='.$month.'&day='.$day.'&cat=25');
- if($yesterday > $lastdate) {
- echo '<a href="' . get_permalink() . '?newsdate='. date ( 'Y-m-j',$yesterday).'">previous day link</a>';
- }
- if($tommorow < $today) {
- echo '<a href="' . get_permalink() . '?newsdate='. date ( 'Y-m-j',$tommorow).'">next day link</a>';
- }
- if($tommorow == $today) {
- echo '<a href="' . get_permalink() . '">next day link</a>';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement