Hello,
Thanks for contacting us.
You must be using a plugin to add a subtitle to your products. As it is not something being added by WooCommerce or WordPress, there is no predefined variable that you can use to show subtitles in the SEO title.
However, you can create a new variable that saves the value of the subtitle in it and use that in the Titles & Meta settings. To create a new variable, please copy and modify the code given below and then paste it into your theme’s/child theme’s functions.php file:
/**
* 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()'
);
});
Hope this helps. Let us know if you need any further assistance.
Thanks for replying. As I am not familiar with JS and WP syntax, so can you help to define the value of custom_variable_slug
and custom_variable_callback()
for subtitle as an example pls? That could be cleaner for me to use it. Thanks a lot!
Hello,
Before doing so, could you please confirm if are you using a custom field for your subtitle (H2), or are you directly adding it to your content?
We are looking forward to helping 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.