Hello,
Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.
A few days ago I published a code that I think you might find useful, you can modify that part of the Schema using this filter, and for example, in this snippet I am adding new URLs to the ‘sameAs’ field, but you could modify everything:
/**
* 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 ) {
$currentSameAs = $data['Organization']['sameAs'];
$currentSameAs[] = "https://wordpress url....";
$currentSameAs[] = "https://blogger url....";
$currentSameAs[] = "https://tumblr url....";
// And so on...
$data['Organization']['sameAs'] = $currentSameAs;
return $data;
}, 10, 2);
Looking forward to helping you. Thank you.
​​​​​​​
Hello,
Thank you for the follow up.
I have tested the following code and it is working on my end. Please try it and let us know:
add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
if ( isset( $data['Organization'] ) ) {
$data['Organization']['sameAs'] = ['https://twitter.com/RankMath', 'https://facebook.com/Rankmath'];
}
return $data;
}, 99, 2 );
Looking forward to helping you. Thank you.
​​​​​​
Hello Michael,
Thanks a bunch… this WORKED!
Hello,
We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.
If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.
If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.
Thank you.
@michaeldavis @albertodel
Something to keep in mind, reviewing:
https://rankmath.com/kb/filters-hooks-api-developer/
it suggests the filter filter being set is at:
}, 10, 2);
When using your code doesn’t work.
But in your working demo code you set the filter to his later at:
}, 99, 2);
Which does work.
Why is documentation saying something different than your code?
Hello,
We will share that with the copywriting team.
If you need help with anything else, please open a new support ticket here so we can help.
We are always here for assistance.