set dynamic post title

#262421
  • Resolved Arundeep Grewal
    Rank Math free

    Hi I am trying to set my wp post title to include the current year using %currentyear% but it isn’t working? It works in my meta data though.

Viewing 1 replies (of 1 total)
  • Nigel
    Rank Math business

    Hello,

    Thank you for contacting Rank Math about setting a dynamic post title using the current year variable.

    The default post title does not support Rank Math variables. To enable support for Rank Math variables you will need to add the following code snippet to your theme’s functions.php file:

    
    function rm_title_replace_vars( $title ) {
        return RankMath\Helper::replace_vars( $title );
    }
    add_filter( 'the_title', 'rm_title_replace_vars', 10, 2 );
    
    add_filter( 'rank_math/frontend/title', function( $title ) {
        $title = get_the_title();
        return $title;
    });
    

    I hope that answers you. Let us know if you have questions. We are here to help.

    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 ‘set dynamic post title’ is closed to new replies.