get_the_content()
must be inside the loop, in header.php you can do this (don’t forget to scape the content to use it as attribute):
if (is_single()) {
while (have_posts()) {
the_post();
$content = get_the_content();
$desc="<meta property="og:description" content="". esc_attr($content) .'">';
echo $desc;
}
}
or even better, in your functions.php hook the wp_head action; also, I recomend using the excerpt instead of the content as descriptoin. (note the use of global $post and setup_postdata).
add_action( 'wp_head', 'my_wp_head' );
function my_wp_head() {
if (is_single()) {
$post_id = get_queried_object_id():
$excerpt = get_the_excerpt( $post_id );
$desc="<meta property="og:description" content="Blabla". esc_attr( $excerpt ) .'">';
echo $desc;
}
//More stuff to put in <head>
}