WordPress.org

Support

Support » How-To and Troubleshooting » get_month_abbrev not working

get_month_abbrev not working

  • I’d really like the month as a three letter string in wp_get archives.
    “OK, why not, sounds good” I hear you all cry”

    but…

    when I try and change this line in wp_get_archives from
    $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);

    to
    $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month_abbrev($arcresult->month), $arcresult->year);

    it returns nothing for the month.

    Ideas peeps?

Viewing 1 replies (of 1 total)
  • Moderator keesiemeijer

    @keesiemeijer

    Don’t hack core WordPress files. Try it with this in your theme’s functions.php:

    add_filter( 'get_archives_link', 'archives_shorten_month');
    
    function archives_shorten_month( $html ) {
            global $wp_locale;
            $html = str_replace( $wp_locale->month, $wp_locale->month_abbrev, $html );
            return $html;
    }

Viewing 1 replies (of 1 total)
  • The topic ‘get_month_abbrev not working’ is closed to new replies.
Skip to toolbar