Skip to content

Instantly share code, notes, and snippets.

@maheshwaghmare
Last active May 20, 2020 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maheshwaghmare/24c4f80396707e3fbbe24100ebe34b59 to your computer and use it in GitHub Desktop.
Save maheshwaghmare/24c4f80396707e3fbbe24100ebe34b59 to your computer and use it in GitHub Desktop.
WordPress SEO - Register current Month custom tag or variable in to the Yoast SEO plugin. We can use the %%current_month%% into the title. . Read more at https://maheshwaghmare.com/doc/yoast-seo-custom-template-variable/
<?php
if( ! function_exists( 'prefix_yoast_register_current_month' ) ) :
/**
* Register current Month variable in Yoast SEO plugin.
*
* @todo Change the `prefix_` with your own custom prefix.
* @since 1.0.0
* @return void
*/
function prefix_yoast_register_current_month() {
wpseo_register_var_replacement( '%%current_month%%', 'prefix_get_current_month', 'advanced', 'Current Month..' );
}
add_action('wpseo_register_extra_replacements', 'prefix_yoast_register_current_month');
endif;
if( ! function_exists( 'prefix_get_current_month' ) ) :
/**
* Return current Month
*
* @todo Change the `prefix_` with your own custom prefix.
* @since 1.0.0
* @return string
*/
function prefix_get_current_month() {
return date("F");
}
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment