How Do I Use RankMath Variables in WordPress Editor?

#466898
  • Resolved Sufyan Khalid
    Rank Math free

    I Want to use Rankmath Variables in my WordPress Editor. Is it possible that how can i use these vaeriables in my Editor to optimize my Headings and Artciles in automation/

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

    Thank you for contacting Rank Math and bringing your concern to our attention.

    Unfortunately, Rank Math’s variables don’t work on the post body or content.

    In this case, you would need to create a custom shortcode that you can insert into your content instead. You can refer to this example code below that gets the current month and year:

    add_shortcode( 'current_month', 'get_current_month');
    function get_current_month () {
        return date("F");
    }
    
    add_shortcode( 'current_year', 'get_current_year');
    function get_current_year () {
        return date("Y");
    }

    The filter should be added to your active theme’s functions.php file. After applying the code above, you can then make use of these shortcodes: [current_month] and [current_year]

    Hope that helps.

    Thank you.

    Bundle of Thanks the code you send to me is work for me.

    Anas
    Rank Math business

    Hello,

    We are glad we could address your concern. 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 ‘How Do I Use RankMath Variables in WordPress Editor?’ is closed to new replies.