Skip to content Skip to main navigation Skip to footer

Add Custom META Description

With Squirrly SEO plugin you can customize the META Description for each URL on your website using the Squirrly SEO Snippet, Squirrly > SEO Settings > Automation or by calling the sq_description hook in your code.

To edit the META Description using the SEO Automation follow the instructions from this URL:
https://howto.squirrly.co/kb/seo-automation/

To edit the META Description using the sq_description hook, activate Squirrly SEO plugin and add this code in function.php file:

//Hook the Squirrly sq_description
add_filter('sq_description', 'custom_squirrly_description', 11);
function custom_squirrly_description($description) {
    return 'My custom META Description';
}

The above code will show the same description for all the pages on your website.

Another solution is to get the post excerpt or the post content and truncate it:

//Hook the Squirrly sq_description 
add_filter('sq_description', 'custom_squirrly_description', 11);
function custom_squirrly_description($description) {
    global $post;
    return  substr($post->post_content, 0, 280);
}

If you want to change the description only for some post IDs you can add the hook like:

//Hook the Squirrly sq_description 
add_filter('sq_title', ' custom_squirrly_description ', 11);
function  custom_squirrly_description($description) {
    global $post;
    switch ($post->ID) {
        case 1:
            $description = 'My Description For Post ID 1';  //for post_id = 1
        case 2:
            $description = 'My Description For Post ID 2';   //for post_id = 2
    }
    //return the title
    return $description;
}

How to customize the META Description using the Squirrly SEO plugin:
https://howto.squirrly.co/kb/bulk-seo/#bulk_seo_snippet_metas

Was This Article Helpful?

Black Friday 2020

Up to 90% OFF on Squirrly SEO, ContentLook, Starbox PRO, Squirrly SOCIAL, Education Cloud 2020, Squirrly SPY