I have created a tag.php
page in the theme. It's working perfectly. I am getting the tags post on the page.
Now I have added the below link to the header.php
page.
<link rel="alternate" hreflang="en-US" href="<?php echo wp_get_canonical_url(); ?>"/>
The above code is showing the canonical URL perfectly on all the pages but when I open my tag page then it's not showing the canonical URL. It's showing the first URL of the post
Any idea what is the issue?
tag.php code below
<?php
/**
* A Simple tag Template
*/
get_header();
?>
<div id="primary" class="content-area">
<main id="main" class="site-main">
<section class="resource-container" id="light-header">
<div class="container">
<?php $tag = get_queried_object();?>
<h1><?php echo $tag->name; ?></h1>
</div>
</section>
</main>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>