Skip to content

Instantly share code, notes, and snippets.

@jpmarchand
Created January 16, 2016 02:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpmarchand/fd412818199d1dc20c03 to your computer and use it in GitHub Desktop.
Save jpmarchand/fd412818199d1dc20c03 to your computer and use it in GitHub Desktop.
<?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