Skip to content

Instantly share code, notes, and snippets.

@mariusghitulescu
Last active December 5, 2018 22:52
Show Gist options
  • Save mariusghitulescu/ec61844b01264c2fa235d38cf20609e7 to your computer and use it in GitHub Desktop.
Save mariusghitulescu/ec61844b01264c2fa235d38cf20609e7 to your computer and use it in GitHub Desktop.
Custom date variable for Yoast SEO
// 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