I have added the following code to my functions.php
function gen_meta_desc() {
global $post;
if (!is_single()) {
return;
}
//print_r($post);
$meta = strip_tags($post->post_content);
$meta = str_replace(array("\n", "\r", "\t"), ' ', $meta);
$meta = substr($meta, 0, 125);
echo "<meta name='description' content='$meta' />";
}
add_action('wp_head', 'gen_meta_desc');
But how do I get the description to output in the header?
I have tried adding <meta name='description' content='$meta' /> in the header but it doesn't work.
What do I do?