The Stack Overflow podcast is back! Listen to an interview with our new CEO.
2 Added link to Wordpress SEO plugin as it may be an alternative solution for the OP
source | link

As mentioned in the comments, you are outside of the loop, so get_field will not know the ID. You can use the code below:

<?php 

    $meta_description = get_field('meta_description', get_the_idget_queried_object_id());

    if(empty($meta_description)) {
        $meta_description = 'This could be an interesting meta description';
    }

?>

<meta name="description" content="<?php echo $meta_description; ?> "/>

If you use var_dump() in the header.php file, you can just add it at the very top, followed by a die() to test:

<?php

var_dump(get_the_idget_queried_object_id());
the_field('meta_description', get_the_idget_queried_object_id());
die();

?><!doctype html>
<html <?php language_attributes(); ?>>.....

Give that a try and let us know how you get on.

Update: You may also want to look at something like the Wordpress SEO plugin as it lets you manage your SEO meta tags without having to edit any code.

As mentioned in the comments, you are outside of the loop, so get_field will not know the ID. You can use the code below:

<?php 

    $meta_description = get_field('meta_description', get_the_id());

    if(empty($meta_description)) {
        $meta_description = 'This could be an interesting meta description';
    }

?>

<meta name="description" content="<?php echo $meta_description; ?> "/>

If you use var_dump() in the header.php file, you can just add it at the very top, followed by a die() to test:

<?php

var_dump(get_the_id());
the_field('meta_description', get_the_id());
die();

?><!doctype html>
<html <?php language_attributes(); ?>>.....

Give that a try and let us know how you get on.

As mentioned in the comments, you are outside of the loop, so get_field will not know the ID. You can use the code below:

<?php 

    $meta_description = get_field('meta_description', get_queried_object_id());

    if(empty($meta_description)) {
        $meta_description = 'This could be an interesting meta description';
    }

?>

<meta name="description" content="<?php echo $meta_description; ?> "/>

If you use var_dump() in the header.php file, you can just add it at the very top, followed by a die() to test:

<?php

var_dump(get_queried_object_id());
the_field('meta_description', get_queried_object_id());
die();

?><!doctype html>
<html <?php language_attributes(); ?>>.....

Give that a try and let us know how you get on.

Update: You may also want to look at something like the Wordpress SEO plugin as it lets you manage your SEO meta tags without having to edit any code.

1
source | link

As mentioned in the comments, you are outside of the loop, so get_field will not know the ID. You can use the code below:

<?php 

    $meta_description = get_field('meta_description', get_the_id());

    if(empty($meta_description)) {
        $meta_description = 'This could be an interesting meta description';
    }

?>

<meta name="description" content="<?php echo $meta_description; ?> "/>

If you use var_dump() in the header.php file, you can just add it at the very top, followed by a die() to test:

<?php

var_dump(get_the_id());
the_field('meta_description', get_the_id());
die();

?><!doctype html>
<html <?php language_attributes(); ?>>.....

Give that a try and let us know how you get on.