Variables in SEO titles and descriptions

#37471
  • Resolved Lê Văn Hiếu
    Rank Math free

    Hello Admin, I have just used RankMath recently and want to be supported!
    1. When using %currentmonth%/%currentyear% RankMath will not display. I think it will display for example 03/2020. The reason is that it is written consecutively and there are no spaces. I think this is an error.
    2. I want to replace the %currentmonth% variable with a number instead of a language display, for example 01, 02, 03, …
    Hope admin supports the above 2 issues. Thank Admin very much!
    I have learned:
    add_filter( ‘rank_math/vars/replacements’, function( $vars ) {
    return $vars;
    });
    But still not working!

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    1). This is expected behavior, you should ensure that all variables are separated by empty space so that they can work normally.

    2). You can add the following code snippet on your theme’s functions.php file to register a new variable that returns the numerical representation of the current month name:

    
    /*
    * A snippet to register a custom variable replacement for Rank Math
    *
    */
    add_action( 'rank_math/vars/register_extra_replacements', function(){
     rank_math_register_var_replacement(
     'Current_Month_Custom',
     [
     'name'        => esc_html__( 'Current month', 'rank-math' ),
     'description' => esc_html__( 'Get and return the current month', 'rank-math' ),
     'variable'    => 'Current_Month_Custom',
     'example'     => my_Current_Month_Custom_callback(),
     ],
     'my_Current_Month_Custom_callback'
     );
    
    });
    
    function my_Current_Month_Custom_callback(){
    	return date('m');
    }

    The variable’s name is %Current_Month_Custom%

    Looking forward to helping you. Thank you.

    ​​​​​​​

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 1 replies (of 1 total)

The ticket ‘Variables in SEO titles and descriptions’ is closed to new replies.