As you said per page/post basis, this would work for each post add_action('wp_head', 'add_link_in_head'); function add_link_in_head(){ global $post; if(!empty($post)){ $alternate = get_post_meta($post->ID, 'alternate', true); $hreflang = get_post_meta($post->ID, 'hreflang', true); if(!empty($alternate) && !empty($hreflang)){?> <link rel="alternate" href="<?php echo $alternate; ?>" hreflang="<?php echo $hreflang; ?>" /><?php }//end of if }//end of if }//end of function If there ia no alternate and hreflang then there would be no link.