For some reason the second get_permalink located on the featured image is pointing to the current page, instead of the post URL.
The first get_permalink works fine. They are both inside the same loop.
I've posted a trimmed down version of the loop below.
The full code for the loop in case it's helpful: https://jsfiddle.net/hemjegzy/
Any help is greatly appreciated.
Loop Code (Trimmed)
<?php
if ( have_posts() ) :
while ( have_posts() ) : the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class( 'post-single-no-sidebar' ); ?>>
<?php if ( is_single() ) { ?>
<?php
the_title( '<h1 class="entry-title">', '</h1>' );
} else {
the_title( '<h1 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h1>' );
}
?>
<a href="<?php get_permalink(); ?>">
<?php the_post_thumbnail(); ?>
</a>
</article>
<?php
endwhile;
endif;
?>
Additional notes:
All plugins and versions of WordPress are up-to-date. I have checked any plugins may be the cause of the issue.
I've looked at answer to:
WP get_permalink Return Wrong URL
Custom post type's get_permalink returns wrong url
Login to wp-admin "redirect_to" points to wrong URL after migration
I do not believe these are the same issues.