Support » Fixing WordPress » get_permalink() returns wrong post

  • Help please—I just made a new post and now instances of <?php echo get_permalink(); ?> and <?php echo get_the_title(); ?> are not working across my entire site. On each post they are are spitting out the link/title to a post from last year instead of the post that is being displayed. Please see what I mean by hitting the Reddit or Like button above the post. I cleared my super cache and optimized my mysql database. I have not installed any new plugins recently, and everything was fine until I posted this most recent post.

Viewing 2 replies - 1 through 2 (of 2 total)
  • I’m not having that problem — all the home page title links go to the correct page.

    Have you tried dumped your browser cache?

    @dianev Thanks for the reply! Yup I did (and in 2 browsers). But I found the answer! The problem seemed to be isolated to the share links on single posts (not the home page). It was because the code for the share links <div> was outside the loop. I moved it inside the loop and it’s working. I had recently moved the share links code to the footer.php and positioned at the top via CSS absolute positioning so as to make the page load faster. I just moved it to the the end of the loop in single.php and problem solved! But it still seems weird that is was returning a random post from last year.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘get_permalink() returns wrong post’ is closed to new replies.