WordPress.org

Ready to get started?Download WordPress

Forums

get_month_abbrev not working (2 posts)

  1. chrispink
    Member
    Posted 2 years ago #

    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?

  2. keesiemeijer
    moderator
    Posted 2 years ago #

    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;
    }

Topic Closed

This topic has been closed to new replies.

About this Topic