To display post meta value from a specific post in header, you can print it like this with specifying post ID instead of variable $post-ID
.
<?php echo get_post_meta( '1234', 'breaking', true ); ?>
get_post_meta
accepts post id and if you only need to show post meta from one specific post then you can define post ID in get_post_meta
and it will always show meta value from 1 post only.
So following will be your updated code. Here 1234
is the ID of your post, you should replace it with yours. Note that you will also need to add post ID in permalink too.
<?php if ( get_post_meta( '1234', 'breaking', true ) ) { ?>
<div>
<a href="https://wordpress.stackexchange.com/questions/163789/<?php echo get_permalink("1234' ); ?> "><?php echo get_post_meta( '1234', 'breaking', true ); ?></a>
</div>
<?php } ?>
EDIT:
Of course it will not work throughout the website for post meta with dynamic post id variable because Archive, category, search, author, tags pages do not have any post ID.
What you can do instead is, print post meta from post/page that have ID but if there is a empty result then print post meta from specific post/page ID.
<?php
global $wp_query;
if ( get_post_meta( $post->ID, 'breaking', true ) ) { ?>
<div><a href="https://wordpress.stackexchange.com/questions/163789/<?php the_permalink(); ?>"><?php echo get_post_meta($postid, 'breaking', true); ?></a></div>
<?php } else { ?>
<div><a href="https://wordpress.stackexchange.com/questions/163789/<?php echo get_permalink("1234' ); ?> "><?php echo get_post_meta( '1234', 'breaking', true ); ?></a></div>
<?php }
wp_reset_query();
?>