-
-
Save jpmarchand/fd412818199d1dc20c03 to your computer and use it in GitHub Desktop.
Link post dates to their archives in WordPress. Source: http://justintadlock.com/archives/2010/08/06/linking-post-published-dates-to-their-archives
This file contains 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 | |
function prefix_link_post_dates() { | |
/* Get the year, month, and day of the current post. */ | |
$year = get_the_time('Y'); | |
$month = get_the_time('m'); | |
$day = get_the_time('d'); | |
$out = ''; | |
/* Add a link to the monthly archive. */ | |
$out.= '<a href="' . get_month_link($year, $month) . '" title="Archive for ' . esc_attr(get_the_time('F Y')) . '">' . get_the_time('F') . '</a>'; | |
/* Add a link to the daily archive. */ | |
$out.= ' <a href="' . get_day_link($year, $month, $day) . '" title="Archive for ' . esc_attr(get_the_time('F d, Y')) . '">' . $day . '</a>'; | |
/* Add a link to the yearly archive. */ | |
$out.= ', <a href="' . get_year_link($year) . '" title="Archive for ' . esc_attr($year) . '">' . $year . '</a>'; | |
return $out; | |
} | |
add_shortcode('post_date_links', 'prefix_link_post_dates'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment