Last active
December 5, 2018 22:52
-
-
Save mariusghitulescu/ec61844b01264c2fa235d38cf20609e7 to your computer and use it in GitHub Desktop.
Custom date variable for Yoast SEO
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
// define the custom replacement callback, returns the date in Jan 2019 format | |
function get_my_date() { | |
return date('M Y'); | |
} | |
// define the action for register yoast_variable replacments | |
function register_custom_yoast_variables() { | |
wpseo_register_var_replacement( '%%my_date%%', 'get_my_date', 'advanced', 'returns the current date' ); | |
} | |
// Add action | |
add_action('wpseo_register_extra_replacements', 'register_custom_yoast_variables'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment