Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have added the Facebook Like button in my Wordpress posts, which in turn use the Open Graph metadata generated by the Wordpress SEO plugin to create stories in Facebook. I am however facing an issue: Each post contains a (JWPlayer) video, but sometimes not an accompanying description. When no description exists, I notice that sometimes the og:description tag is set to something (somehow) irrelevant, such as the description of a related post or even comments. Hence, what I am trying to achieve is: when there is an actual description accompanying the post then set the og:description to that description, else set the og:description to something default e.g. "Hello world". I have fiddled a bit with the plugin and found this chunk of code in wordpress-seo/frontend/class-opengraph.php:

if ( is_singular() ) {
        $ogdesc = wpseo_get_value( 'opengraph-description' );
        if ( !$ogdesc )
            $ogdesc = $this->metadesc( false );

        // og:description is still blank so grab it from get_the_excerpt()
        if ( !$ogdesc ) 
            $ogdesc = strip_tags( get_the_excerpt() );
}
$ogdesc = apply_filters( 'wpseo_opengraph_desc', $ogdesc );

And have modified it as such:

if ( is_singular() ) {
        $ogdesc = wpseo_get_value( 'opengraph-description' );
        if ( !$ogdesc )
            $ogdesc = $this->metadesc( false );

        // og:description is still blank so grab it from get_the_excerpt()
        if ( !$ogdesc ) {
            if($post->post_content=="") {
                $ogdesc = 'Hello World' . ' - ' . $this->options['og_frontpage_desc'];
            } else {
                $ogdesc = strip_tags( get_the_excerpt() );
            }
        }
    }
    $ogdesc = apply_filters( 'wpseo_opengraph_desc', $ogdesc );

The problem now is that all posts trigger the 'Hello World' line in og:description even when there is an accompanying description with the post.

What am I missing here? Can anyone guide me to the right direction? Bear in mind that I'm not very familiar with Wordpress's functions.

Thanks!

P.S. Running on Wordpress 3.5.2

share|improve this question
    
hey guys, just an update that i still havent managed to fix this –  globetrotter Aug 5 '13 at 3:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.