Skip to content

Instantly share code, notes, and snippets.

@jpmarchand jpmarchand/link-post-dates.php Secret
Created Jan 16, 2016

Embed
What would you like to do?
<?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
You can’t perform that action at this time.