Hello,
here’s some updates
In the front-end the title is correct – %customterm(brand)% – recognize the brand and %customterm(product_cat)% – recognize the category title
The problem persist in the back-end where in snippet title is like this:
Custom term value test-sku | Test title | Custom term value |
How can be fix this?
Also I have a few questions:
– is it possible to add a custom term with custom value?
– how can I add priceValidUntil, aggregateRating, review, EAN/Gtin? I already have this data in custom fields.
Thanks
Ricky
Hello,
Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.
I am not really sure if I fully understand your problem, is it that you have the right title in the frontend but the preview doesn’t show the right data?
About your other questions:
– Yes, you can a custom term, with this code:
/**
* Action: 'rank_math/vars/register_extra_replacements' - Allows adding extra variables.
*/add_action( 'rank_math/vars/register_extra_replacements', function(){
rank_math_register_var_replacement(
'custom_variable_slug',
[
'name' => esc_html__( 'Custom variable name.', 'rank-math' ),
'description' => esc_html__( 'Custom variable description.', 'rank-math' ),
'variable' => 'custom_variable_slug',
'example' => 'custom_variable_callback()',
],
'custom_variable_callback()'
);
});
– You should create a custom PHP code to get the values from those custom fields and add them to the Rank Math’s Rich Snippet Data, for example, for the Brand field you do this:
// Add Brand for Products.
add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
$entity['brand'] = 'Rank Math;
return $entity;
});
Looking forward to helping you. 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.