Hello,
I apologize for the inconvenience you’re facing. To display the current month and year in the SEO title as “[12/2023]”, you can use the following shortcode: %currentmonth%/%currentyear%
.
This will format the output to show the month and year in the desired format.
If you have any other questions or need further assistance, feel free to ask.
Thank you for reaching out!
Sources:
Using Variables in the SEO Title and Description » Rank Math
Set the Current Year in Post Title Using the [year] Shortcode » Rank Math
WordPress Permalink Structure & Changing Individual URLs » Rank Math
Rank Math General Settings
Hi, it is still Dezember/2023
Hi there,
Thanks for reaching out to us. We’re glad to help you with your query.
You want to show the current date in the SEO title as “[12/2023]”, right? That’s easy to do with Rank Math. You just need to create a new Rank Math variable that will output the date in that format.
Here’s how you can do it:
- Copy and paste the following code into your website’s child theme
functions.php
file or a code snippet plugin:
/**
* Action: 'rank_math/vars/register_extra_replacements' - Allows adding extra variables.
* Snippet to register variable that will return the current date in the format m/Y
*/
add_action('rank_math/vars/register_extra_replacements', function () {
rank_math_register_var_replacement(
'custom_current_date',
[
'name' => esc_html__('Custom Current Date', 'rank-math'),
'description' => esc_html__('Custom Current date in the format m/Y', 'rank-math'),
'variable' => 'custom_current_date',
'example' => custom_current_date_callback(),
],
'custom_current_date_callback'
);
});
function custom_current_date_callback()
{
return date('m/Y'); // returns the current date in the format m/Y
}
- Save the changes and clear any cache on your site.
- Go to Rank Math > Titles & Meta > Posts (or any other post type) and edit the SEO title field. You can also do this directly on the post
- Add the variable
%custom_current_date%
where you want the date to appear. For example, “My Awesome Post %custom_current_date%”
- Save the changes and check your SEO title on the front end. It should look like this: “My Awesome Post [12/2023]”
That’s it! You have successfully created and used a custom Rank Math variable to display the current date in the SEO title.
If you want to change the date format, you can edit the line return date('m/Y');
in the code and use any of the date formats listed here: https://wordpress.org/documentation/article/customize-date-and-time-format/
We hope this solves your issue. If you have any other questions or feedback, please let us know. We’re always happy to hear from you.
Thank you for using Rank Math!
Hello,
We’re just following up with you to see if you have any other questions or concerns that we can assist you with. Or, if your issue has been resolved, please let us know so we can mark this ticket as closed.
We appreciate your patience and cooperation throughout this process. Your feedback is valuable to us and helps us improve our service.
Thank you for choosing Rank Math.
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.