0

On the homepage of a WordPress website the latest posts are visible. In the dashboard it's set to display 10 posts on the home page.

However, it loads 133 posts. Switching to the default theme didn't make any difference.

The version of WordPress is updated.

Where should we start debugging the problem?

  • Start by disabling all your plugins and see if the issue still exists – swissspidy Jan 22 '18 at 9:25
  • @swissspidy Thanks! Totally forgot about that technique – Ionică Bizău Jan 22 '18 at 9:34
  • @swissspidy Disabled all. It doesn't make any change. – Ionică Bizău Jan 22 '18 at 9:45
  • @DHL17 Sorry, what code? That's what I'm asking: I have no idea where to start debugging this. Changing the theme to default and disabling the plugins didn't make any change. – Ionică Bizău Jan 22 '18 at 11:09
  • ok. which theme u r using currently? – DHL17 Jan 22 '18 at 12:19
2

The theme is most likely altering the main query via the pre_get_posts hook, chaning the posts_per_page argument to -1 for all posts, or another higher number.

You can search your theme folder for pre_get_posts to see all the times this hook is used.

A better solution would be to install the Query Monitor. With this plugin installed and active, you get a wealth of information about each page request.

To use it, login as admin and visit your homepage once the plugin is active. The admin bar will have a new options. Click the new option (looks like a bunch of numbers) and choose the "Hooks & Actions" section. From there, select "Pre" from the "Hook" dropdown and it will list all where the pre_get_posts hooks is being called.

query monitor hooks and actions section

| improve this answer | |
  • Thanks for the answer. But even when using the default theme, the problem persists. Query Monitor looks like a useful plugin. – Ionică Bizău Jan 22 '18 at 11:10
  • The "Queries" section of Query Monitor will allow you to see the SQL for the main query. Sometime looking at that can provide clues to what might be altering it. – Andrew Jan 22 '18 at 11:17
  • IIRC you can also see the stack trace of the queries – Mark Kaplun Jan 22 '18 at 11:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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