Hello,
Thank you for contacting Rank Math today.
No, we have set that to Product by default.
What else do you want to set it to?
Looking forward to helping you.
I would like to set it to music as I use edd to distribute my music
Hello,
You can use the following filter code to change the Product schema:
add_filter( "rank_math/json_ld", function( $data, $jsonld ) {
if ( ! is_singular( 'product' ) ) {
return $data;
}
unset( $data['richSnippet'] );
$product_id = $jsonld->post_id;
// Use get_post_meta( $product_id, '_meta_key', true ); to get the meta value for event
$data['richSnippet'] = array(
'@context' => 'https://schema.org',
'@type' => 'MusicEvent',
'name' => $jsonld->parts['title'],
'description' => $jsonld->parts['desc'],
'url' => $jsonld->parts['url'],
'eventStatus' => get_post_meta( $product_id, '_meta_key', true ),
'location' => array(
'@type' => 'Place',
'name' => 'Venue Name',
'url' => 'venue_url',
'address' => array(
'@type' => 'PostalAddress',
'streetAddress' => 'Street Address',
'addressLocality' => 'Address Locality',
'addressRegion' => 'Address Region',
'postalCode' => 'Postal code',
'addressCountry' => 'Country',
),
),
'startDate' => '2019-03-06T15:20',
'endDate' => '2019-03-06T15:20',
'performer' => array(
'@type' => 'Person',
'name' => 'Jack'
),
);
return $data;
}, 20, 2 );
Hope that helps. If you have any further question(s), please let us know.
Hi
I see you set the type to music event.
This is not what I need. I’m a composer. I need the music composition type.
Wouldn’t it be more simple to let users chose the snippet type they want like for all the other post types ?
Hello,
As per the Google guidelines, schema should only contain the data which is related to the article and visible on the frontend and since Woocommerce and EDD plugins are based on the products, we are adding the Product snippet there.
This is not what I need. I’m a composer. I need the music composition type.
Do you want Composer schema: https://schema.org/composer? If so, you can change the code I gave you above and add the fields which are needed for the Composer schema.
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.