Display short form of Months instead of long form

#242881
  • Resolved Arafat
    Rank Math free

    I follow this post: https://support.rankmath.com/ticket/display-short-form-of-months-instead-of-long-form-jan-and-not-january/ to Display a short form of Months.


    /**
    * A custom replacement variable to get the current month in custom format
    */

    add_action( 'rank_math/vars/register_extra_replacements', function(){
    rank_math_register_var_replacement(
    'current_month_M',
    [
    'name' => esc_html__( 'Current month', 'rank-math' ),
    'description' => esc_html__( 'Current server time displaying month in custom format', 'rank-math' ),
    'variable' => 'current_month_M',
    'example' => custom_date_callback(),
    ],
    'custom_date_callback()'
    );
    });

    function custom_date_callback(){

    return date_i18n( 'M' );

    }

    After active snippet show this: There has been a critical error on this website. show this error only when I use this short code current_month_M

    Check this: https://tinyurl.com/yzt4z8yk

    Please solve this issue ASAP!

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thanks for contacting us. Sorry for the delay and any inconvenience that might have been caused due to that.

    I have replaced the code with the code given below:

    add_action( 'rank_math/vars/register_extra_replacements', function(){
     rank_math_register_var_replacement(
     'current_month_M',
     [
     'name'        => esc_html__( 'Current month', 'rank-math' ),
     'description' => esc_html__( 'Current server time displaying month in custom format', 'rank-math' ),
     'variable'    => 'current_month_M',
     'example'     => custom_date_callback(),
     ],
     'custom_date_callback'
     );
    });
    
    function custom_date_callback(){
    	
    	return date_i18n( 'M' );
    	
    }

    It just has a minor change that when calling custom_date_callback function, you shouldn’t use parenthesis. Now the variable is working fine.

    Please check and confirm. Let us know if you need any further assistance.

    Arafat
    Rank Math free

    It’s now working.

    Thanks

    Ankit
    Rank Math business

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

The ticket ‘Display short form of Months instead of long form’ is closed to new replies.