Last active
May 19, 2021 14:40
-
-
Save wp-seopress/b662b58209734394e04251d523dfb667 to your computer and use it in GitHub Desktop.
Filter the list of predefined dynamic variables for automatic schemas
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
add_filter('seopress_schemas_mapping_select', 'sp_schemas_mapping_select'); | |
function sp_schemas_mapping_select($select) { | |
//Add the new group option + option to the list | |
$select['Custom variables'] = [ | |
'my_custom_var_key' => __('My super custom var', 'wp-seopress-pro'), | |
]; | |
return $select; | |
} | |
add_filter('seopress_schemas_dyn_variables', 'sp_schemas_dyn_variables'); | |
function sp_schemas_dyn_variables($vars) { | |
//add the variable key | |
$vars[] = 'my_custom_var_key'; | |
return $vars; | |
} | |
add_filter('seopress_schemas_dyn_variables_replace', 'sp_schemas_dyn_variables_replace'); | |
function sp_schemas_dyn_variables_replace($values) { | |
//replace the new key by our own value | |
//eg: author last name | |
$values[] = get_the_author_meta('last_name'); | |
return $values; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment