Last active
May 20, 2020 17:34
-
-
Save maheshwaghmare/4b4f94eb5b2a4670dd3b966edbd44014 to your computer and use it in GitHub Desktop.
WordPress SEO - Register current Year custom tag or variable in to the Yoast SEO plugin. We can use the %%current_year%% into the title. Read more at https://maheshwaghmare.com/doc/yoast-seo-custom-template-variable/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if( ! function_exists( 'prefix_yoast_register_current_year' ) ) : | |
/** | |
* Register current Year 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_year() { | |
wpseo_register_var_replacement( '%%current_year%%', 'prefix_get_current_year', 'advanced', 'Current Year..' ); | |
} | |
add_action('wpseo_register_extra_replacements', 'prefix_yoast_register_current_year'); | |
endif; | |
if( ! function_exists( 'prefix_get_current_year' ) ) : | |
/** | |
* Return current Year | |
* | |
* @todo Change the `prefix_` with your own custom prefix. | |
* @since 1.0.0 | |
* @return string | |
*/ | |
function prefix_get_current_year() { | |
return date("Y"); | |
} | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment