Title: Missing description in FB Opengraph
Last modified: August 30, 2016

---

# Missing description in FB Opengraph

 *  [jlcota](https://wordpress.org/support/users/jlcota/)
 * (@jlcota)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/missing-description-in-fb-opengraph/)
 * Hi,
 * I’m editing Functions.php to generate FB Opengraph metatags, everything right
   till now but I can’t get the post description.
 * My code is:
 *     ```
       function fb_opengraph() {
           global $post;
   
           if(is_single()) {
               if(has_post_thumbnail($post->ID)) {
                   $img_src = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), ‘medium’);
       $img_src = $img_src[0];
               } else {
                   $img_src = get_stylesheet_directory_uri() . '/img/opengraph_image.jpg';
               }
               if($excerpt = $post->post_excerpt) {
                   $excerpt = strip_tags($post->post_excerpt);
                   $excerpt = str_replace("", "'", $excerpt);
               } else {
                   $excerpt = get_bloginfo('description');
               }
               ?>
       ```
   
 * I’m obtaining an empty string in $excerpt
 * Any help would be appreciated.
 * Cheers

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [bdbrown](https://wordpress.org/support/users/bdbrown/)
 * (@bdbrown)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/missing-description-in-fb-opengraph/#post-6776250)
 * Hi jlcota. Try changing this:
 *     ```
       if($excerpt = $post->post_excerpt) {
       ```
   
 * to this:
 *     ```
       if($excerpt == $post->post_excerpt) {
       ```
   
 * Reference: [http://php.net/manual/en/language.operators.comparison.php](http://php.net/manual/en/language.operators.comparison.php)
 *  Thread Starter [jlcota](https://wordpress.org/support/users/jlcota/)
 * (@jlcota)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/missing-description-in-fb-opengraph/#post-6776297)
 * Doesn’t work 🙁
 *  [bdbrown](https://wordpress.org/support/users/bdbrown/)
 * (@bdbrown)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/missing-description-in-fb-opengraph/#post-6776303)
 * Looks like there are a couple of closing brackets } missing. Don’t know if that
   has anything to do with it. What happens if you remove the if/else construct 
   from the excerpt block and just leave this line?
 *     ```
       $excerpt = get_bloginfo('description');
       ```
   
 *  Thread Starter [jlcota](https://wordpress.org/support/users/jlcota/)
 * (@jlcota)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/missing-description-in-fb-opengraph/#post-6776306)
 * Yes, that works.
 * But if I try:
 * > $excerpt = $post->post_excerpt);
 * I’m getting an empty string.
 * Cheers
 * Jorge
 *  [bdbrown](https://wordpress.org/support/users/bdbrown/)
 * (@bdbrown)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/missing-description-in-fb-opengraph/#post-6776307)
 * Perhaps this might be the answer:
    [http://wordpress.stackexchange.com/questions/158972/how-to-get-post-or-page-excerpt-using-post-excerpt](http://wordpress.stackexchange.com/questions/158972/how-to-get-post-or-page-excerpt-using-post-excerpt)
 *  Thread Starter [jlcota](https://wordpress.org/support/users/jlcota/)
 * (@jlcota)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/missing-description-in-fb-opengraph/#post-6776338)
 * Thanks bdbrown but I can’t make it work yet.
 * Is there any other way to generate the right OG metatags with the Hueman theme?
 * Cheers,
 * Jorge
 *  [bdbrown](https://wordpress.org/support/users/bdbrown/)
 * (@bdbrown)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/missing-description-in-fb-opengraph/#post-6776339)
 * I don’t know anything about FB OG metatags other than what I’ve read online. 
   I doubt that it’s an issue with the theme. There are plugins that say they will
   create the metatags, and [this article](http://www.wpbeginner.com/wp-themes/how-to-add-facebook-open-graph-meta-data-in-wordpress-themes/)
   describes a couple of different plugins and manually adding the code.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Missing description in FB Opengraph’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/hueman/3.7.27/screenshot.png)
 * Hueman
 * [Support Threads](https://wordpress.org/support/theme/hueman/)
 * [Active Topics](https://wordpress.org/support/theme/hueman/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/hueman/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/hueman/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [bdbrown](https://wordpress.org/support/users/bdbrown/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/missing-description-in-fb-opengraph/#post-6776339)
 * Status: not resolved