I noticed that for some reason on my site, the post order changes depending on whether a user is logged in or not. When I am logged in as the admin, the posts display is chronological order. But when I log out, the oldest post is displayed first, then chronological order, and then the newest post is at the bottom. What is going on here?

Update: I checked my theme's functions.php file and the extras.php file (which includes extra functions) and neither of them have any filters affecting the post order.

Update: I changed my theme to Twenty Sixteen and am still having this issue. I also am on a clean install of Wordpress. Then I updated Wordpress to make sure I didn't accidently change something but I still have the issue.

closed as off-topic by Pieter Goosen, TheDeadMedic, Mark Kaplun, birgire, Sumit Jun 22 '16 at 15:41

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?" – Pieter Goosen, TheDeadMedic, Mark Kaplun, birgire, Sumit
If this question can be reworded to fit the rules in the help center, please edit the question.

  • You have a custom filter which is causing this behavior. Do basic debugging and you will find out which plugin is causing this, or it could be an issue within your theme – Pieter Goosen Jun 21 '16 at 6:19
  • I am using a modified version of the underscores.me starter theme. Every version of this theme seems to have that same problem for me but I don't know why. Would the filter be in functions.php? – 5AMWE5T Jun 22 '16 at 2:41
  • That is what you should debug. The filters should be in functions.php or any file that is used as a custom functions file – Pieter Goosen Jun 22 '16 at 4:26
  • By clean, do you mean that you also have no plugins installed or activated. This is really a strange issue which I have never seen. – Pieter Goosen Jun 22 '16 at 5:18
  • I deactivated all the plugins to see if any of them were causing the issue and it turns out none of them were, so I reactivated them. – 5AMWE5T Jun 22 '16 at 5:46

I found out what was causing this problem. I had a plugin installed called Simple Posts Generator which I used to generate 10 sample posts for testing purposes. Since I generated the articles all at the same time, the post_date value in the database was the same for each post, which confused Wordpress as to what post should come first.

I fixed it by going into the database and manually changing the post_date values so they are all different, which solved the problem. Now all my posts are sorted correctly in chronological order.

  • never ever never ever use query_posts. Find your bug and fix it instead :( – Mark Kaplun Jun 22 '16 at 4:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.