Disabling Yoast, All-in-One, and Rank Math on Certain Pages within a Plugin


I developed a custom plugin for a site that is using URL rewriting within WordPress to create several dynamic pages. When one of these custom pages is loaded, I’m using the following functions and filters to create custom page titles and meta descriptions:

// page title

// meta tags

This works beautifully to create custom, dynamically generated page titles and meta descriptions. That is, until I enable ANY SEO plugin (Yoast, All-in-One, Rank Math, etc.).

I need to use these plugins on the blog and standard pages on the website, but I want to disable them from running only when one of my custom pages/URLs is running. I came across this code:

// JetPack
// Yoast SEO
if (defined('WPSEO_VERSION'))
    global $wpseo_front;
// All-In-One SEO
if (defined('AIOSEOP_VERSION'))
    global $aiosp;

I’ve tried running it within the function that calls the custom page, as well as the functions mp_custom_page_title and mp_custom_metatag_display, but no luck.

How can I disable these plugins on these pages? Any insight is greatly appreciated!

, , Dexter 10 months 2020-04-29T17:10:40-05:00 0 Answers 85 views 0

Leave an answer