使用get_the_time()
, get_month_link()
和get_year_link()
:
function wpse_58787_archive_link()
{
$Y = get_the_time( \'Y\' ); // year
$m = get_the_time( \'m\' ); // month as number
$F = get_the_time( \'F\' ); // month as word
return \'Archived in <a href="\' . get_month_link( $Y, $m ) . \'">\' . $F . \'</a>
<a href="\' . get_year_link( $Y ) . \'">\' . $Y . \'</a>\';
}
print wpse_58787_archive_link();