Forum
Blog Article Excerpt Reused
I am trying to reuse the blog article excerpt as the meta description.
Should I create a separate layout for the head content just for the blog post or create a different seo.html changing the content id for the blog excerpt?
I tried this in a blog head content:
<meta name="description" content="<?php perch_blog_post_field(perch_get('s'), 'excerpt', striptags=true); ?>" />
But while it output the text okay it had <p> tags around it, however I think its coded wrong as my editor is showing an error.
Can you advise?
You should use a template - then you can add the
striptags
attribute you're attempting to implement.How would I pull in an article excerpt in a template?
Create a template containing the excerpt tag.
Use
perch_blog_custom()
to display the post using that new template.Okay I have got it working by adapting my original code:
and changing the code in the post.html to
It works, however some characters are not outputting correctly e.g. an ampersand is ' the only way I can avoid this currently is using the Æ character. Any ideas what I can do to translate this character?
? and ! output fine.
Do you have an example?
I think its something to do with html entities? Maybe this is just the way it is?
BTW I typed
but it translated in the post correctly as a '
Thats what I want to happen when it is in the meta description.
I'm sorry, I know you're explaining it, but I really can't grasp the problem. I'll try fresh in the morning!