Forum

Thread tagged as: Problem, Meta, Blog

Blog Excerpt in Meta Property og:description

I'm adding a Facebook "Like" button to my blog story page which uses the "post.html" template. Within the page <head> tags I'm including:

<meta property="og:description" content="<?php perch_blog_post_field(perch_get('s'), 'excerpt'); ?>" />

"excerpt" is included in my "Post.html" template as:

<perch:blog id="excerpt" label="Excerpt" type="textarea" editor="markitup" textile="true" order="1" size="s" suppress="true" order="3" />

I'm using perch_blog_post_field to include other meta properties such as og:title ('postTitle'), og:url ('postURL'), and og:image ('image'). All of these work correctly. But for some reason 'excerpt' does not output a value when I look at my page in Facebook's Open Graph Output Debugger. Am I missing something?

Thank you.

Marco Bario

Marco Bario 0 points

  • 7 years ago

What appears in the meta tag if you view source? It might be upset if you have HTML tags e.g. <p>hello</p> in there.

You could try something like:

<?php 
  $excerpt = strip_tags(perch_blog_post_field(perch_get('s'), 'excerpt', true));
?>

<meta property="og:description" content="<?php echo $excerpt ?>" />

Thank you Tom. Your solution worked perfectly!