Hello,
Thank you for contacting Rank Math and bringing your concern to our attention.
Rank Math makes it possible for you to take a control of your SEO and you can easily extend the Rank Math JSON-LD output by making use of the following filter:
/**
* Collect data to output in JSON-LD.
*
* @param array $unsigned An array of data to output in json-ld.
* @param JsonLD $unsigned JsonLD instance.
*/
add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
return [];
}, 10, 2);
The filter should be added to your active theme’s functions.php file. Here’s another way to apply the filter using the rankmath.php file:
https://rankmath.com/kb/filters-hooks-api-developer/#adding-filters-and-hooks-in-rank-math-php
Here’s a sample filter you can use and customize to start with:
add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
if ( isset( $data['publisher'] ) ) {
$data['publisher']['sameAs'] = [
'https://www.instagram.com/example',
'https://www.facebook.com/example',
'https://www.facebook.com/groups/example',
'https://www.youtube.com/channel/example',
'https://linkedin.com/example'
];
}
return $data;
}, 99, 2 );;
Hope that helps.
Thank you.
Thank you @Reinelle for these details. I have added the above code by creating rank-math.php file.
But, I have still questions!
If you look at the above link’s BlogPost Schema, they have Citation + ReviewedBy section too! So,
How can I add Citations to SCHEMA?
How can I add the reviewer’s name to SCHEMA? How will rank math detect who is the reviewer here?
—
Further, I just added new fields in the users’ profile section using this code:
add_filter( 'user_contactmethods', 'modify_user_contact_methods' );
function modify_user_contact_methods( $methods ) {
// Add user contact methods
$methods['facebook'] = __( 'Facebook' );
$methods['instagram'] = __( 'Instagram' );
$methods['twitter'] = __( 'Twitter username (without @)' );
$methods['linkedin'] = __( 'Linkdin' );
$methods['skype'] = __( 'Skype' );
// Remove user contact methods
unset( $methods['aim'] );
unset( $methods['jabber'] );
return $methods;
}
But, Rank Math is not adding these new social links in the user/author’s sameAs section in the SCHEMA.
Hello,
It is impossible at the moment for Rank Math to pick those data automatically. You may need to assign those fields and point them to our schema properties using the filter our colleague provided in the first reply.
That filter is versatile and you can remove, add or extend the entire schema structure.
Hope that helps.
Thank you.
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.