Created
April 17, 2016 04:12
-
-
Save akiya64/e19bea2a383ae7da0aad83bfdce6fc61 to your computer and use it in GitHub Desktop.
shirohanada
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php if(is_month()){ | |
| //Previous - Next Month Nav// | |
| $before_post_month = strtotime(get_the_time('Y-m')." -1 month"); | |
| $before_month = array ( | |
| "year" => date('Y', $before_post_month), | |
| "month" => date('m', $before_post_month), | |
| ); | |
| $before_month_link = get_month_link($before_month['year'], $before_month['month']); | |
| $after_post_month = strtotime(get_the_time('Y-m')." +1 month"); | |
| $after_month = array ( | |
| "year" => date('Y', $after_post_month), | |
| "month" => date('m', $after_post_month), | |
| ); | |
| $after_month_link = get_month_link($after_month['year'], $after_month['month']); | |
| echo '<a href="'.$before_month_link.'"><i class="icon icon-angle-left"></i>Older '.date('Y.m', $before_post_month).'</a>'; | |
| echo '<a href="'.$after_month_link.'">'.date('Y.m', $after_post_month).'Newer <i class="icon icon-angle-right"></i></a>'; | |
| }elseif(is_date()){ | |
| //Previous - Next Month Nav | |
| $before_post_day = strtotime(get_the_time('Y-m-d')." -1 day"); | |
| $before_day = array ( | |
| "year" => date('Y', $before_post_day), | |
| "month" => date('m', $before_post_day), | |
| "day" => date('d', $before_post_day), | |
| ); | |
| $before_day_link = get_day_link($before_day['year'], $before_day['month'], $before_day['day']); | |
| $after_post_day = strtotime(get_the_time('Y-m-d')." +1 day"); | |
| $after_day = array ( | |
| "year" => date('Y', $after_post_day), | |
| "month" => date('m', $after_post_day), | |
| "day" => date('d', $after_post_day), | |
| ); | |
| $after_day_link = get_day_link($after_day['year'], $after_day['month'], $after_day['day']); | |
| echo '<a href="'.$before_day_link.'" class="previous-day"><i class="icon icon-angle-left"></i>'.date('Y.m.d', $before_post_day).'</a>'; | |
| echo '<a href="'.$after_day_link.'" class="next-day">'.date('Y.m.d', $after_post_day).'<i class="icon icon-angle-right"></i></a>'; | |
| }else{ | |
| echo '<a href="'.get_month_link('', '').'">Recent Posts</a>'; | |
| } | |
| ?> |
Author
Author
リンクテキストに日付を表示したい、などには使い回せると思う。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
WordPress method exists, rewrite this.