-
I have a custom post type (“movies”) for which I am programmatically creating the og tags.
Can I disable the og tags for this custom post type?
Can I disable all RankMath output for this custom post type?Thanks,
James
-
Hello,
Thank you for contacting Rank Math today.
Yes you can disable the OG tags for a certain post type by using the following code snippet:
/** * Hook to remove og:tags for sepcific post type */ add_action( 'rank_math/head', function() { //replace post_type_name with the name of the post type if(is_singular('post_type_name')){ remove_all_actions( 'rank_math/opengraph/facebook' ); remove_all_actions( 'rank_math/opengraph/twitter' ); } });
It is also possible to remove all the Rank Math output for the post type by using the following snippet:
/* * * Disable Rank Math for non WP pages * */ add_action( 'wp_head', 'rankmath_disable_features',1); function rankmath_disable_features() { if(is_singular('post_type_name')) { remove_all_actions( 'rank_math/head'); } }
Looking forward to helping you. Thank you.
Michael, thanks for the quick response!
Hello James,
I am so glad to be of help. We are always here if you need us in the future.
Hey, if it isn’t too much to ask for – would you mind leaving us a review here?
https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post
It only takes a couple of minutes but helps us tremendously.
It would mean so much to us.
Thank you.
Hi Michael,
The code to remove RankMath on post type it works for me but I only want to disable Rankmath on a single post type so how can I do it.
Thank youHello,
What do you mean with disable? Because the code Michael shared is used to remove Rank Math in specific post types so it should work fine.
Looking forward to help you.
Hi,
Like in my post type ‘casino’ has 8 items. I only want to disable on 1 item
ThanksHello,
Thank you for contacting Rank Math today.
I assume you want to remove Rank math for a specific post under the post-type casinos, which I am afraid is a filter we don’t have currently.
Hoping this helps you. Thank you.
Hi @Michael Davis
I got this message and want to disable Rankmath for them.
Rank Math has detected new post types: ct_template, piotnetforms, piotnetforms-book. You may want to check the settings of the Titles & Meta page and the Sitemap.
Is this correct? If it works, I should see no Rankmath fields in those post type? Thank you.
/* * * Disable Rank Math for non WP pages * */ add_action( 'wp_head', 'rankmath_disable_features',1); function rankmath_disable_features() { if(is_singular('piotnetforms','piotnetforms-book','ct_template')) { remove_all_actions( 'rank_math/head'); } }
Hello @HsinYu,
Thank you for contacting Rank Math support today.
Please refer to this code if you wish to select multiple custom post types:
add_action( 'wp_head', 'rankmath_disable_features',1); function rankmath_disable_features() { if(is_singular(array('piotnetforms','piotnetforms-book','ct_template'))) { remove_all_actions( 'rank_math/head'); } }
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
Hi @Jeremy
I am sorry but it doesnt work. I expect the rankmath custom fields will be gone for those CPT. Here are a few screenshots for your investigation. Thanks a million.
And will the Titles & Meta tabs for those CPT on rankmath be gone.
Hello @Hsin Yu,
Oh, it seems that you are referring to the CPT listed on the Titles & Meta settings. The filter that we provided should only disable the head meta elements generated by Rank Math on the frontend.
Looking forward to helping you.
You must be logged in to reply to this ticket.