Hello,
Thank you for contacting Rank Math support today and bringing your concern to our attention.
You might need to further extend your schema structure by customizing our filter code here: https://rankmath.com/kb/filters-hooks-api-developer/#extend-json-ld-data
After you customize the filter code to edit your schema structure, you may apply the code to your themeās functions.php file.
Hope this helps you with your situation. Looking forward to helping you on this one.
Thank you.
Hello again,
I dont know how to properly insert this code
"alternateName": [
"LISER CUBIERTAS"
]
in this funtion
add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
return [];
}, 99, 2);
Hello,
Please refer to this filter code instead:
add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
if ( isset( $data['publisher'] ) ) {
$data['publisher']['alternateName'] = [
'LISER CUBIERTAS'
];
}
return $data;
}, 99, 2 );
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
Hello,
Glad that helped.
Please feel free to reach out to us again in case you need any other assistance.
We are here to help.
Thank you.
Hello again, I would like to put more than one alternateName. How shoud I insert it in the filter?
"alternateName": [
"LISER CUBIERTAS",
"Tejados LISER"
]
I tried this and didnt work:
add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
if ( isset( $data['publisher'] ) ) {
$data['publisher']['alternateName'] = ['LISER CUBIERTAS'];
$data['publisher']['alternateName'] = ['Tejados LISER'];
}
return $data;
}, 99, 2 );
Thanks
Hello,
You can simply add more items inside the array instead of assigning a new one. Please refer to my filter code here:
add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
if ( isset( $data['publisher'] ) ) {
$data['publisher']['alternateName'] = [
'LISER CUBIERTAS',
'Tejados LISER'
];
}
return $data;
}, 99, 2 );
This code should work and shouldn’t cause any issues when you check it in the Rich Result Test.
Let us know how that goes. Looking forward to helping you.
Hello,
If you have any questions in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.
Thank you.