SiteSEO provides a way to add custom variables using hooks
Hook: siteseo_schemas_mapping_select, siteseo_schemas_dyn_variables, siteseo_schemas_dyn_variables_replace
Since: 1.0.0
Usage:
function siteseo_extended_schemas_mapping_select($select) {
//Add the new group option + option to the list
$select['Custom variables'] = [
'my_custom_var_key' => __('Your Custom variable', 'siteseo'),
];
return $select;
}
add_filter('siteseo_schemas_mapping_select', 'siteseo_extended_schemas_mapping_select');
function siteseo_extended_schemas_dyn_variables($vars) {
//add the variable key
$vars[] = 'my_custom_var_key';
return $vars;
}
add_filter('siteseo_schemas_dyn_variables', 'siteseo_extended_schemas_dyn_variables');
function siteseo_extended_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;
}
add_filter('siteseo_schemas_dyn_variables_replace', 'siteseo_extended_schemas_dyn_variables_replace');
Note: We suggest you use siteseo_extended_ as a prefix for every callback function, to keep things consistent and non-conflicting.