Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#50204 closed defect (bug) (wontfix)

wp_query_reset seems to reset the loop and not the query

Reported by: elieobeid7's profile elieobeid7 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Query Keywords:
Focuses: docs, coding-standards Cc:


I'm not going to bother posting it here because reformatting from markdown to whatever formatting this issue tracker accepts takes time and you're not going to fix the bug anyhow, you're going to defend your naming conventions and design conventions and you're going to tell me how and why I'm wrong, so not worth my time posting it here.

It's on Reddit, if you want to fix it that's awesome, if not then at least I wouldn't have wasted my time.

Change History (4)

#1 @ravipatel
4 years ago

Use wp_reset_query() to wp_reset_postdata().

@elieobeid7 this one not the right place for a post a question.

Last edited 4 years ago by ravipatel (previous) (diff)

This ticket was mentioned in Slack in #core by ravi. View the logs.

4 years ago

#3 @apedog
4 years ago

Perhaps you're looking for this function - wp_reset_postdata()?

You're actually asking for a widely-used function to be renamed because the naming convention is bad?
WordPress is a patchwork. Its full of inconsistently named APIs and functions, and mismatched function signatures etc.
The trade-off is that backward-compatibility is assured.
Changing the naming convention will break backward-compatibility.
But you already knew that:

you're going to defend your naming conventions and design conventions

I'm guessing you're right - no one is going to fix this "bug". The WordPress design philosophy (AFAIK) is that backward-compatibility trumps good naming conventions.

#4 @peterwilsoncc
4 years ago

  • Component changed from General to Query
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

As mentioned above, the purpose of wp_reset_query() is to reset any changes to the main query, otherwise known as the loop.

To rewind the current query/loop to the first post requires calling rewind_posts().

As these function have been in WordPress for a very long time, you are correct that they're unlikely to change. As such, I'm going to close this ticket wontfix.

Discussion can continue on a closed ticket, for further support on customising the main loop or using this functions is best found in the support forums as there are more people able to assist you in them.

Note: See TracTickets for help on using tickets.