get_permalink not fetching correct pages
get_permalink will fetch the URL of the current post within a loop. If you call it on an archive page, then what WP thinks is the “current post” is actually the first post that you are about to loop through and so you end up with that post’s permalink rather than the current page’s URL. … Read more