I was trying to use the_content as my meta description, however, i noticed that the texts/content is way too many so I'm thinking if it's possible to use the first paragraph only?
Here's the code I'm currently using for meta description.
<?php global $post;
$content = $post->post_content; if(!empty($content)) {?>
<meta property="og:description" content="<?php echo strip_tags($content); ?>" />
<?php }?>
Btw, The first paragraph of my the_content has a class. f-desc and here's the code I've used to add it.
function first_paragraph($content){
return preg_replace('/<p([^>]+)?>/', '<p$1 class="f-desc">', $content, 1);
}
add_filter('the_content', 'first_paragraph');