Support » How-To and Troubleshooting » [Resolved] get_the_content for meta tag not working
6 years, 7 months ago
<meta name="description" content="<?php echo get_the_content(); ?>" />
I need to know what is wrong with this.. It returns “content” on my facebook share.
eg. http://www.nullweknow.com is my site.
Thanks in advance.
Get_the_content() only works in the loop which is why it doesn’t work for you. there’s a way to do what you want, but I don’t have the answer handy. I’ll look it up when I get home.
echo $post->post_content; will echo your post content. Keep in mind though, it’s raw out of the database (same as get_the_content()). If you want to apply the same filters that the_content() receives, follow the instructions in the codex:
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
Wow, thanks for the reply.. Imma go test that out.
Works like a charm. Thanks bro.
No problem, glad to help.