Title: Remove Yoast fields programatically for a CPT
Last modified: September 26, 2021

---

# Remove Yoast fields programatically for a CPT

 *  Resolved [Jairo Ochoa](https://wordpress.org/support/users/jairoochoa/)
 * (@jairoochoa)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/remove-yoast-fields-programatically-for-a-cpt/)
 * Hi
 * Is there any hook which allows to remove Yoast fields programatically?
    Even 
   it can be done in Yoast settings I would like to add this feature to a plugin
   I’m developing.
 * Thanks

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [Suwash Kunwar](https://wordpress.org/support/users/suascat_wp/)
 * (@suascat_wp)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/remove-yoast-fields-programatically-for-a-cpt/#post-14910963)
 * [@jairoochoa](https://wordpress.org/support/users/jairoochoa/)
 * If you would like to remove the SEO settings from the Custom Post Type you’ve
   registered programmatically, you can do that by going to SEO > Search Appearance
   > Content Types(tab) where you’ll see the option to Toggle off the setting to
   disable the SEO metabox on the posts of Custom Post Type you have.
 * If this was not what you’re looking for, could you please explain which Yoast
   Settings would you like to remove for a CPT?
 *  Thread Starter [Jairo Ochoa](https://wordpress.org/support/users/jairoochoa/)
 * (@jairoochoa)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/remove-yoast-fields-programatically-for-a-cpt/#post-14917844)
 * Hi
 * Yes, the new CPT “business” was created programatically but this is no the question.
 * What I meant is: since this CPT exists, I want to remove SEO settings for this
   CPT in the Add/Edit page of this CPT.
 * I know that I can enter SEO > Search Appearance > Content Types > Business (business)
   and set OFF the option “Show SEO settings for Business?”
    But I want do it programatically.
 * Why I do not want to enter Yoast Settings and do it as described?
    Because I 
   want to fire this option when my plugin is activated. The user could forget to
   do it and I can save him time if the plugin do this task programatically.
 * If is there any hook to do it, I would like to know what is.
 * Please, let me know if now is clear what I want to do or if I have to provide
   you more information.
 * Regards,
    Jairo
 *  Plugin Support [Michael Tiña](https://wordpress.org/support/users/mikes41720/)
 * (@mikes41720)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/remove-yoast-fields-programatically-for-a-cpt/#post-14926967)
 * Hi [@jairoochoa](https://wordpress.org/support/users/jairoochoa/)
 * Modifying the options in the Search Appearance menu is currently the only way
   to make sure the Yoast SEO meta box and settings don’t appear for your chosen
   CPT.
 * If you want to do this programmatically, you may have to refer to our developer
   portal for all documentation, should you want to modify the plugin output – [https://developer.yoast.com/](https://developer.yoast.com/)
 *  Thread Starter [Jairo Ochoa](https://wordpress.org/support/users/jairoochoa/)
 * (@jairoochoa)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/remove-yoast-fields-programatically-for-a-cpt/#post-14927397)
 * Hi [@mikes41720](https://wordpress.org/support/users/mikes41720/)
 * Thanks, I’ll check the developer portal.
 * Regards
 *  Thread Starter [Jairo Ochoa](https://wordpress.org/support/users/jairoochoa/)
 * (@jairoochoa)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/remove-yoast-fields-programatically-for-a-cpt/#post-14927524)
 * Hello again [@mikes41720](https://wordpress.org/support/users/mikes41720/),
 * I’ve found this code:
 *     ```
       add_action( 'template_redirect', 'remove_wpseo' );
   
       /**
        * Removes output from Yoast SEO on the frontend for a specific post, page or custom post type.
        */
       function remove_wpseo() {
           if ( is_single ( 1 ) ) {
               $front_end = YoastSEO()->classes->get( Yoast\WP\SEO\Integrations\Front_End_Integration::class );
   
               remove_action( 'wpseo_head', [ $front_end, 'present_head' ], -9999 );
           }
       }
       ```
   
 * This prevents Yoast’s fields be shown in the front, but fields would still be
   stored in the database.
    What I want is not to modify plugin output. What I want
   is that these fields do not exist in the WP-admin so they won’t exist in the 
   frontend.
 * I will check developer portal again.
 * PS: This site has about 70,000 items of the CPT and I want to avoid that unnecessary
   data being stored in the database. 70,000 items are too many records and if Yoast
   adds a bunch of custom field per post, they are toooo many unnecessary records
   in the database.
 * Regards,
    Jairo
 *  [devnihil](https://wordpress.org/support/users/devnihil/)
 * (@devnihil)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/remove-yoast-fields-programatically-for-a-cpt/#post-14929600)
 * [@jairoochoa](https://wordpress.org/support/users/jairoochoa/) Unfortunately 
   we can’t offer support on custom code. Since we don’t want to take the risk that
   we break your website by suggesting incorrect or incomplete code, we cannot advise
   you on how to make such changes. Maybe someone watching these forums can assist
   you further, but if your topic is inactive for 7 days, we’ll mark it as resolved
   to keep the overview.
 * Thank you for your understanding.
 *  Thread Starter [Jairo Ochoa](https://wordpress.org/support/users/jairoochoa/)
 * (@jairoochoa)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/remove-yoast-fields-programatically-for-a-cpt/#post-14929653)
 * Hi [@devnihil](https://wordpress.org/support/users/devnihil/)
 * This is the question that started this topic:
 * > Is there any hook which allows to remove Yoast fields programatically?
 * So, if there is no hook I will decide another way to do it.
 * Thanks

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Remove Yoast fields programatically for a CPT’ is closed to new replies.

 * ![](https://ps.w.org/wordpress-seo/assets/icon-256x256.gif?rev=3419908)
 * [Yoast SEO - Advanced SEO with real-time guidance and built-in AI](https://wordpress.org/plugins/wordpress-seo/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordpress-seo/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordpress-seo/)
 * [Active Topics](https://wordpress.org/support/plugin/wordpress-seo/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordpress-seo/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordpress-seo/reviews/)

 * 7 replies
 * 4 participants
 * Last reply from: [Jairo Ochoa](https://wordpress.org/support/users/jairoochoa/)
 * Last activity: [4 years, 8 months ago](https://wordpress.org/support/topic/remove-yoast-fields-programatically-for-a-cpt/#post-14929653)
 * Status: resolved