Skip to content

Instantly share code, notes, and snippets.

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 wp-seopress/b662b58209734394e04251d523dfb667 to your computer and use it in GitHub Desktop.
Save wp-seopress/b662b58209734394e04251d523dfb667 to your computer and use it in GitHub Desktop.
Filter the list of predefined dynamic variables for automatic schemas
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