wordpress : cant access $wp_locale->get_month(9) from a plugin file

I am trying to create a simple wordpress plugin and I have to invoke $wp_locale->get_month($month) function, but it returns a fatal error

function test()
{
    global $wp_locale;
    echo $wp_locale->get_month($month);
}

Error –> Fatal error: Call to a member function get_month() on a
non-object in…..

Read More

.

Related posts

Leave a Reply

2 comments

  1. The global is simply not available yet when you’re trying to call it.

    This works:

    add_action( 'init', function()
    {
        global $wp_locale;
        var_dump( $wp_locale->get_month(2) );
        die();
    });