Skip to contentSkip to main navigation Skip to footer

Developers

Deactivating Specific Features in Squirrly SEO Plugin Using Hooks

How to deactivate specific features from the Squirrly SEO plugin using hooks in the functions.php file:

  1. Deactivating Features in the Frontend:
if (!is_admin()) {
    // Deactivate Squirrly Open Graph in the frontend
    add_filter('sq_open_graph', '__return_false', 11);

    // Deactivate Squirrly Twitter Card in the frontend
    add_filter('sq_twitter_card', '__return_false', 11);

    // Deactivate Squirrly Rich Snippet in the frontend
    add_filter('sq_json_ld', '__return_false', 11);
}
  1. Deactivating Features in the Backend:
// Deactivate Squirrly Open Graph feature
add_filter('sq_option_sq_auto_facebook', '__return_false');

// Deactivate Squirrly Twitter Card feature
add_filter('sq_option_sq_auto_twitter', '__return_false');

// Deactivate Squirrly Rich Snippet feature
add_filter('sq_option_sq_auto_jsonld', '__return_false');
  1. Deactivating Specific Rich Snippet Features:
// Deactivate meta title
add_filter('sq_option_sq_auto_title', '__return_false');

// Deactivate meta description
add_filter('sq_option_sq_auto_description', '__return_false');

// Deactivate keywords meta
add_filter('sq_option_sq_auto_keywords', '__return_false');

// Deactivate canonical meta
add_filter('sq_option_sq_auto_canonical', '__return_false');

// Deactivate robots meta
add_filter('sq_option_sq_auto_noindex', '__return_false');

// Deactivate DublinCore meta
add_filter('sq_option_sq_auto_dublincore', '__return_false');

// Deactivate favicon meta
add_filter('sq_option_sq_auto_favicon', '__return_false');

// Deactivate sitemap xml meta
add_filter('sq_option_sq_auto_sitemap', '__return_false');

// Deactivate webmasters meta
add_filter('sq_option_sq_auto_webmasters', '__return_false');

// Deactivate analytics meta
add_filter('sq_option_sq_auto_tracking', '__return_false');

// Deactivate meta pixels
add_filter('sq_option_sq_auto_pixels', '__return_false');

Make sure to add these code snippets to your theme’s functions.php file. These hooks will disable specific features of the Squirrly SEO plugin in both the frontend and backend. Use the is_admin condition to avoid disabling the features in backend.

Hook Squirrly Title & Description With Custom Data

To customize the Squirrly SEO Title and Description with data from wp_postmeta using the provided hooks, you can follow these steps:

  • Open your theme’s functions.php file or a custom plugin file where you want to add these filters.
  • Add the following code to customize the Squirrly SEO Title and Description using the add_filter function:

For Title:

add_filter('sq_title', function ($title){
    global $post;
    if ($custom = get_post_meta($post->ID, '_sq_title', true)) {
        return $custom;
    }
    return $title;
}, 11);

For Description:

add_filter('sq_description', function ($description){
    global $post;
    if ($custom = get_post_meta($post->ID, '_sq_description', true)) {
        return $custom;
    }
    return $description;
}, 11);

Explanation:

  • We use the add_filter function to hook into the sq_title and sq_description filters provided by the Squirrly SEO plugin.
  • Inside the filter functions, we use get_post_meta to retrieve the custom SEO title and description stored in the _sq_title and _sq_description post meta fields, respectively.
  • We check if a custom title or description exists. If it does, we return the custom value; otherwise, we return the original title or description.
  • We set the priority of the filter to 11 to ensure that it runs after the default Squirrly SEO filter.
  • Save your functions.php file or the custom plugin file.
  • Now, whenever you have a post or page with a custom _sq_title or _sq_description value in the post meta, it will override the default SEO title and description provided by the Squirrly SEO plugin.

Make sure that you have the Squirrly SEO plugin installed and activated for these filters to work, as they rely on the plugin’s filters and functionality.