Ready to get started?Download WordPress


get_permalink() returns wrong post (3 posts)

  1. ryanve
    Posted 4 years ago #

    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.

  2. DianeV
    Posted 4 years ago #

    I'm not having that problem — all the home page title links go to the correct page.

    Have you tried dumped your browser cache?

  3. ryanve
    Posted 4 years ago #

    @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.

Topic Closed

This topic has been closed to new replies.

About this Topic