Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Maybellyne

    (@maybellyne)

    Hello Stephen,

    Thanks for reaching out about disabling Yoast SEO for custom pages.

    Is places a custom post type? You can disable the feature on specific post types without adding code to your theme’s functions.php file. Please take a look at https://yoast.com/help/how-to-enable-disable-the-keyword-analysis/

    Thread Starter stephenoconnor

    (@stephenoconnor)

    Thanks Maybellyne – no it’s not a custom post type – it’s built with a plugin that creates a url structure to combine 2 taxonomies, so it’s an unusual situation – for example in rankmath i was able to add code to the functions file like this, but i wonder is there something similar for yoast

    <?php
    add_action( 'wp_head', 'rankmath_disable_features',1);
    function rankmath_disable_features() {
      if (strpos($_SERVER['REQUEST_URI'], "/places/") !== false){
    	remove_all_actions( 'rank_math/head');
    	 }
    }
    ?>
    Thread Starter stephenoconnor

    (@stephenoconnor)

    Any feedback?

    Thread Starter stephenoconnor

    (@stephenoconnor)

    i suppose it will be

    <?php
    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 (strpos($_SERVER['REQUEST_URI'], "/places/") !== false){
            $front_end = YoastSEO()->classes->get( Yoast\WP\SEO\Integrations\Front_End_Integration::class );
    
            remove_action( 'wpseo_head', [ $front_end, 'present_head' ], -9999 );
        }
    }
    ?>

    thanks anyway

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Disable Yoast on pages with particular string in URL’ is closed to new replies.