Hello Michael,
Thank you for contacting Rank Math today.
It is possible to remove Rank Math data on the product pages. Would you like to remove all Rank Math data on the header or just OpenGraph and meta description since these are the ones that are duplicated?
Looking forward to helping you. Thank you.
That is great news Michael. How do I go about doing that?
On product pages generated by Ecwid I’d need to remove RankMath canonical link, meta data, og data and schema data I think. I don’t think I need to remove breadcrumb (but that might change I don’t know as yet).
Hi Michael,
Thank you for the follow up.
You can use the following code on your theme’s functions.php file to remove Rank Math meta info apart from the title:
add_action( 'wp_head', function(){
if( is_singular('enter_product_post_type_name_here')) {
remove_all_actions( 'rank_math/head' );
add_action( 'wp_head', '_wp_render_title_tag', 2 );
}
}, 1 );
Looking forward to helping you. Thank you.
And could I run that within a code snippet or do I have to go into functions.php direct? It would be great if I can run that as a snippet so I’ll be less likely to break anything
Hi Michael,
Thanks for the follow up.
Yes you can run this as a snippet. Since you mentioned before that you are not using WooCommerce on your store, you will need to pass the custom post type name on this section. If it is product for example, you can have this code:
add_action( 'wp_head', function(){
if( is_singular('product')) {
remove_all_actions( 'rank_math/head' );
add_action( 'wp_head', '_wp_render_title_tag', 2 );
}
}, 1 );
I hope this helps.
Hi Michael, thanks very much for getting back to me. Where can I find out the custom post type name you are talking about?
Hello,
Thank you for contacting Rank Math today.
You can check your custom post types here: Rank math> Titles & Meta> Post types
The default post types are usually Posts, Pages and Attachments.
I hope this helps.
Hi Michael, thanks for that. I can see the Products type as you have highlighted:
https://www.dropbox.com/s/5q20yba9srht3ac/rank-math-produts-type.jpg?dl=0
And I’ve run that code you provided for product as a snippet:
https://www.dropbox.com/s/lc4xkpxzk0xs3qj/remove-product-header-snippet.jpg?dl=0
I have cleared the wordpress cache, and the browser cache. And the CDN is disabled. But when I check view source on a product page I still see the RankMath header code:
https://www.dropbox.com/s/x5kkmbfdtf05ai9/rankmath-header-code-remains.jpg?dl=0
Please could you advise? Thanks very much.
Michael.
Hi Michael,
Are you using WooCommerce on that website to show products? I think you aren’t and I don’t imagine this part would work on non-WooCommerce products:
if( is_singular('product'))
You have to contact Ecwid and ask them what the equivalent for that is in their plugin.
Just update product
in the above code with that and you should be good to go.
Hi Todd,
Thank you for getting back to me. I’m using the Ecwid store plugin. I will revert to Ecwid and pass on what you’ve said. I sincerely hope I’ll be good to go once they reply with the correct product section.
Hello,
Thank you for the info.
We too hope they will be able to help with the issue.
Please do not hesitate to let us know if you need our assistance with anything else.
Hi Michael thank you for putting this together for me. Please can you clarify what I should enter when you say enter_product_post_type_name_here
. Would you mind please giving me a working example for say this product page:
https://reclaimdesign.org/home-decor-shop/Test-Tube-Vases-With-Stand-p134947241
And would I be able to add all 10 pages within that function?
Thank you for your assistance.
Hello,
Thank you for getting back to us.
I am afraid that I cannot tell from the URL. We might need to take a closer look at the settings. Please edit the first post on this ticket and include your WP logins in the designated Sensitive Data section.
It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:
https://wordpress.org/plugins/temporary-login-without-password/
You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):
https://wordpress.org/plugins/wp-security-audit-log/
We really look forward to helping you.
Hi Michael, thanks for getting back to me. I think the logon details are still in your system from a previous post? Would you mind checking please?
Hi Michael,
I am sorry but you will need to contact your ECWid plugin developers for that.
They will have the correct product type name for you to replace in the code we provided.
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.