I'm displaying list or archives using

<?php get_archives('monthly', '', 'html', '', '', FALSE); ?>

and my list displays

December 2012 November 2012 etc

However I would like to format this to display:

12.12 11.12 10.12 etc

Any ideas?

  • 2
    Don't know about the date format unfortunately, but get_archives has been deprecated and replaced with wp_get_archives – jzatt Dec 4 '12 at 11:09

There is but the filter sucks, it only gives you the link HTML:

add_filter( 'get_archives_link', 'wpse74891_archives_link' );
function wpse74891_archives_link( $link ) {
    $link = preg_replace_callback( '/>([A-Za-z]+\s+\d{4})/', function( $matches ) {
        return '>' . date( 'm.y', strtotime( $matches[1] ) );
        }, $link );
    return $link;

Using this method you can pass in any date format you want for the link at least.

  • mate you are star, that did the trick :) – jmysona Dec 4 '12 at 17:27

Try changing the date display format under Settings > General in your WordPress admin. Choose the custom option and enter y.m into the box.

enter image description here

If you're feeling adventurous, there are lots of other formatting tags available

  • The date format in settings only applies to post dates - the archive links are kinda hard coded. – sanchothefat Dec 4 '12 at 12:05
  • yes that doesn't work – jmysona Dec 4 '12 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.