Skip to contentSkip to main navigation Skip to footer

Deactivating Specific Features in Squirrly SEO Plugin Using Hooks

Squirrly SEO Deactivating Specific Features in Squirrly SEO Plugin Using Hooks screen on a laptop

Squirrly SEO has WordPress filters that turn a feature off, remove one group of tags from a page, or change the title and description it prints. You add them in PHP, in a must-use plugin or in your child theme, and the saved settings in Squirrly > All Features stay as they are.

Every filter name and argument below comes from the code of Squirrly SEO 14.2.8.

Where to add the code

  1. Create the folder wp-content/mu-plugins/ if your site doesn’t have it.
  2. Add a file named squirrly-custom.php that starts with <?php.
  3. Paste the filters you need under that line and upload the file.

WordPress loads must-use plugins before Squirrly SEO, so every filter is in place in time. Squirrly checks the Sitemap XML, Robots.txt File and Llms.txt File switches while it loads, before the theme runs. A sq_option_ filter for those three works only from a must-use plugin. The other filters on this page also work from the functions.php file of a child theme.

Turn a feature off with sq_option_

Squirrly reads its settings with SQ_Classes_Helpers_Tools::getOption(), which passes the saved value through the filter sq_option_ followed by the option key. Return false and Squirrly acts as if the switch were off, in the admin and on the site.

// Turn off Open Graph, Twitter Card and JSON-LD
add_filter( 'sq_option_sq_auto_facebook', '__return_false' );
add_filter( 'sq_option_sq_auto_twitter', '__return_false' );
add_filter( 'sq_option_sq_auto_jsonld', '__return_false' );

The filter changes the value Squirrly reads, not the one stored in the database. Remove the line and the saved setting is back. While the filter is active, the switch in the admin shows off, and screens that depend on it leave the menu. With sq_auto_facebook and sq_auto_twitter both off, Technical SEO > Social Media is hidden.

Squirrly SEO All Features card for On-Page SEO METAs
The On-Page SEO METAs card shows the value of sq_auto_metas, the option the filter overrides.

Option keys you can filter

Switch in SquirrlyOption keyWhat off means
On-Page SEO METAssq_auto_metasNo title, description, keywords, canonical, robots or Dublin Core tags
Optimize the Titlessq_auto_titleNo title tag from Squirrly
Optimize Descriptionssq_auto_descriptionNo meta description
Optimize Keywordssq_auto_keywordsNo meta keywords
Add Canonical Meta Linksq_auto_canonicalNo canonical and no prev/next links
Add Robots Metasq_auto_noindexNo robots meta
Add Dublin Core Metasq_auto_dublincoreNo Dublin Core tags
Open Graph Optimizationsq_auto_facebookNo Open Graph tags
Twitter Card Optimizationsq_auto_twitterNo Twitter Card tags
JSON-LD Structured Datasq_auto_jsonldNo JSON-LD script
Sitemap XMLsq_auto_sitemapNo Squirrly sitemap (must-use plugin only)
Robots.txt Filesq_auto_robotsSquirrly stops serving robots.txt (must-use plugin only)
Llms.txt Filesq_auto_llmsSquirrly stops serving llms.txt (must-use plugin only)
Favicon Site Iconsq_auto_faviconNo icon links from Squirrly
Webmaster Toolssq_auto_webmastersNo verification codes
Google Analytics Trackingsq_auto_trackingNo Google Analytics script
Facebook Pixel Trackingsq_auto_pixelsNo Facebook Pixel
Inner Linkssq_auto_innelinksNo inner links added to the content
SEO Linkssq_auto_linksNo nofollow or new tab on external links
SEO Automationsq_auto_patternSquirrly stops applying the Automation patterns
Auto-Indexingsq_auto_indexnowLLM Indexing stops and leaves the menu

The same filter turns a feature on with '__return_true'. SEO Metas explains the meta switches one by one, and Advanced Settings covers the loading options.

Remove one group of tags from a page

Squirrly builds the head of each page from a list of filters. Each one starts as false, Squirrly fills it at priority 10, and it turns the result into HTML tags at priority 99. Return false from your own filter and that group is left out of the page.

FilterRemoves
sq_titleThe title tag
sq_descriptionThe meta description
sq_keywordsThe meta keywords
sq_canonicalThe canonical link
sq_noindexThe robots meta
sq_dublin_coreThe Dublin Core tags
sq_open_graphThe Open Graph tags
sq_twitter_cardThe Twitter Card tags
sq_json_ldThe JSON-LD script
sq_google_analyticsThe Google Analytics script
sq_facebook_pixelThe Facebook Pixel
sq_verifyThe webmaster verification codes
sq_faviconThe icon links

This is the way to remove tags from some pages only, because the option filters above work for the whole site. The example takes Open Graph and Twitter Card off WooCommerce product pages and leaves them everywhere else:

add_filter( 'sq_open_graph', 'my_sq_no_social_on_products', 11 );
add_filter( 'sq_twitter_card', 'my_sq_no_social_on_products', 11 );
function my_sq_no_social_on_products( $tags ) {
    if ( is_singular( 'product' ) ) {
        return false;
    }
    return $tags;
}

The old version of this tutorial wrapped the frontend filters in if ( ! is_admin() ). They run only on the site, so the condition isn’t needed.

Change the title and description with custom data

At priority 11, sq_title and sq_description get plain text: the value from the SEO Snippet or from the SEO Automation pattern. Squirrly then cleans the text at priority 98 and puts it in the tag at 99.

Title from a custom field

This example reads a custom field named my_seo_title. Change the name to the field your site uses.

add_filter( 'sq_title', 'my_sq_title_from_field', 11 );
function my_sq_title_from_field( $title ) {
    if ( ! $title || ! is_singular() ) {
        return $title;
    }
    $custom = get_post_meta( get_queried_object_id(), 'my_seo_title', true );
    return $custom ? $custom : $title;
}

Keep the first check. Squirrly passes false when the title is off for that page, and then it doesn’t wrap the value in a title tag. Text returned at that point would land in the head as plain text.

Description from a custom field

add_filter( 'sq_description', 'my_sq_description_from_field', 11 );
function my_sq_description_from_field( $description ) {
    if ( ! $description || ! is_singular() ) {
        return $description;
    }
    $custom = get_post_meta( get_queried_object_id(), 'my_seo_description', true );
    return $custom ? $custom : $description;
}

At priority 98 Squirrly removes scripts, styles and HTML tags from the description, so a field that holds HTML still prints plain text. Add Custom META Description covers the other two ways to set it.

Keywords

add_filter( 'sq_keywords', 'my_sq_keywords', 11 );
function my_sq_keywords( $keywords ) {
    if ( is_singular( 'product' ) ) {
        return 'wet cat food,cat food for kittens';
    }
    return $keywords;
}

Return one string with commas between the keywords. At priority 20 Squirrly adds the post tags when Add the Post tags in Keyword META is on, and the tag is printed only while Optimize Keywords is on. Both options show in SEO Metas in SEO Expert mode.

Hide Squirrly tools in the admin

FilterReturn false and
sq_load_slaThe Live Assistant box leaves the editor and the Squirrly column leaves the posts list
sq_load_snippetThe SEO Snippet is hidden, and AI Research, Optimize Posts and Bulk SEO show a permission message
sq_load_cssSquirrly’s frontend CSS file isn’t loaded
sq_load_bufferSquirrly doesn’t read the page output, so it adds no tags to the head

The first two take the user into account when you check the role inside the filter. Squirrly User Roles has an example for Authors. Remove the Squirrly fontend.css shows the CSS options.

Other filters for developers

FilterArgumentsWhat you can change
sq_canonical_url$urlThe URL in the canonical link, og:url and twitter:url
sq_og_article_author$author, $postThe article:author value in Open Graph
sq_post_images$imagesThe images Squirrly picks for Open Graph and the Twitter Card
sq_json_ld_data$dataThe JSON-LD data before it’s printed
sq_structured_data_type_for_page$typesThe schema types of the page
sq_custom_robots$robots (text)The full robots.txt text
sq_custom_llms$llms (text)The full llms.txt text
sq_buffer$bufferThe whole HTML of the page (Squirrly adds its tags at priority 10)

Add Custom JSON-LD Structured Data and How To Customize the Squirrly SEO Snippet Image have worked examples for two of them.

Troubleshooting

The filter has no effect

Clear the page cache first, then view the source again. If the filter is for the sitemap, robots.txt or llms.txt switch, move it from functions.php to a must-use plugin.

The tags are missing in the page builder preview

Squirrly doesn’t add its metas while Elementor, Divi, Bricks and the other builders show their preview. Check the live page instead.

My sq_title filter gets false

Squirrly has no title for that page. Automation shows “Squirrly SEO is not active on this post type.” for an excluded type, the page can have Activate Squirrly Snippet for this page off, or Optimize the Titles is off. Return the value unchanged in that case.

A setting shows off and I can’t turn it on

An sq_option_ filter on the site returns false for it. Search the theme and the must-use plugins for sq_option_.

Frequently asked questions

Does sq_option_ change my saved settings?

No, it only changes the value Squirrly reads while the code is active.

Which priority should I use?

Use 11 for sq_title, sq_description and sq_keywords, so your code gets the plain text before Squirrly wraps it.

Do these filters need the Advanced Pack?

No, they are all in the free Squirrly SEO plugin.

Can I turn off Squirrly on one page without code?

Yes, switch off Activate Squirrly Snippet for this page in the SEO Snippet of that page.

Was This Article Helpful?

Before you leave

Future of AEO GEO and AI Search!

Free Now. Free Forever.

It’s time to stop orbiting SaaS.

Be the Meteor.

10 Elite Tools. 1 Stack.