I have used ACF hundreds of times but never to edit the meta description.
I have created a simple text field in ACF, then tried to use this script:
<?php
$meta_description = get_field('meta_description'); ?>
<?php if ($meta_description != '') : ?>
<meta name="description" content="<?php echo $meta_description; ?>"/>
<?php else : ?>
<meta name="description" content="This could be an interesting meta description"/>
<?php endif; ?>
But, it doesn’t acknowledge the field, it simply does the ‘else’ from the if statement.
Here is a screenshot of my ACF set-up:

Do I need to sanitise the field or call it earlier or something? Not sure why this would work so well for all other fields but this one.
Here is the field being filled in on the pages:

Is this even possible?
Any help would be great!
Ta, Jason.
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.