Support » Plugin: SEOPress, on-site SEO » set default og:description for post

  • Resolved medtr

    (@medtr)


    Hi,
    first of all let me thank you for developing this great plugin.
    i want to set a default og:description so it will be used when no content is found (for meta descriptin template i use post_excerpt. some of my posts have just a download links which are managed by another plugin thats why seopress detect them as empty excerpt and dont incldude og:description meta tag.
    i found a solution using seopress_social_og_desc filter and its working good for me.
    here is my code

    function sp_social_og_desc($html) { 
    	if(seopress_titles_the_description_content() ==''){
        $html = '<meta property="og:description" content="my default description" />'; 
        }
        return $html;
    }
    add_filter('seopress_social_og_desc', 'sp_social_og_desc');

    i just want to know is this good? do you have any suggestion?
    Thank you

    • This topic was modified 3 months, 3 weeks ago by medtr.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Benjamin Denis

    (@rainbowgeek)

    Hi,

    a little bit better:

    function sp_social_og_desc($html) { 
    	if (function_exists('seopress_titles_the_description_content') && seopress_titles_the_description_content() !='') {
        	$html = '<meta property="og:description" content="my default description" />'; 
        }
        return $html;
    }
    add_filter('seopress_social_og_desc', 'sp_social_og_desc');

    I have added a check on the function. It’s always a good practice (in case the plugin is deactivated for some reasons, or the function is deprecated…).

    thank you so much.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.