Hello,
Thank you for contacting the support.
Please add the following code to your theme’s functions.php file and see if that helps.
Filter code to change Schema to Event on WC Products page:
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 );
Let us know how it goes.
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.