Hello,
I apologize for the inconvenience you are facing with removing Twitter meta tags using code. If you want to disable the Twitter meta tags generated by Rank Math with code directly, you can use the following snippet:
add_filter( 'rank_math/opengraph/twitter_card', '__return_false' );
This code will disable the Twitter Card type output in the Twitter card. By using this filter, you can prevent the Twitter meta tags from being added to your website.
If you encounter any further issues or need additional assistance, please feel free to let us know.
Thank you for reaching out and raising your concern. Have a great day!
Sources:
How to Disable All Rank Math Generated SEO Tags » Rank Math
Rank Math SEO Filters and Hooks for Developers – Rank Math
How to Make Your Theme Rank Math Compatible » Rank Math
How to Enhance Sharing in Slack » Rank Math
It didn’t work. I added it to my theme’s function and it didn’t work.
Hello,
Thank you for your patience.
You can use these filters to remove the Twitter meta tags added by the Slack Enhanced Sharing option in Rank Math:
add_filter( 'rank_math/opengraph/slack/twitter_data1', '__return_false');
add_filter( 'rank_math/opengraph/slack/twitter_label1', '__return_false');
add_filter( 'rank_math/opengraph/slack/twitter_data2', '__return_false');
add_filter( 'rank_math/opengraph/slack/twitter_label2', '__return_false');
Here is a guide you can follow to add the filter:
https://rankmath.com/kb/wordpress-hooks-actions-filters/
Looking forward to helping you.
Thanks for the reply but I already checked for the hook name removed it using
remove_all_actions( 'rank_math/opengraph/slack' );
Hello,
You are right. The filter you shared should also remove the remaining Twitter meta tags.
You can continue with that filter.
Please do not hesitate to let us know if you need our assistance with anything else.
Thanks.