#7080 closed defect (bug) (duplicate)
a new WP_Query created in the loop, whose the_post() method is called, messes around with wp_the_query - "recent entries" widget is still loop-breaking
| Reported by: | msi08 | Owned by: | Denis-de-Bernardy |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Query | Version: | 2.7 |
| Severity: | normal | Keywords: | needs-patch |
| Cc: | Focuses: |
Description
I'm using a "related posts" plugin and I noticed a problem with the ID of the current post when the "recent entries" widget is used as the first widget. I found a solution somewhere in the internet but I'm surprised that it's still not a part of the trunk.
I don't know who to credit for (maybe Google can help), but here is the fix, I found and use.
Attachments (1)
Change History (21)
#1
@
17 years ago
- Component General → Widgets
- Keywords has-patch 2nd-opinion added
- Milestone 2.9 → 2.8
- Owner removed
- Version → 2.7
#3
@
17 years ago
- Milestone Future Release
- Resolution → invalid
- Status new → closed
invalid, given how wp_reset_query() behaves
#4
@
17 years ago
- Milestone → 2.8
- Resolution invalid
- Status closed → reopened
annoyingly, I just ran into this one myself.
#5
@
17 years ago
- Keywords 2nd-opinion removed
patch doesn't help much either.
to reproduce, do the following in the loop:
the_title(); the post's title
insert widget here
the_content(); the content of the widget's last post
#7
@
17 years ago
- Owner set to
- Status reopened → assigned
it's occurring around the_post(), but I can't figure out what it might be.
#9
@
17 years ago
- Summary "recent entries" widget is still loop-breaking → the_post() called on an arbitrary query messes around with wp_the_query - "recent entries" widget is still loop-breaking
#10
@
17 years ago
- Summary the_post() called on an arbitrary query messes around with wp_the_query - "recent entries" widget is still loop-breaking → a new WP_Query created in the loop, whose the_post() method is called, messes around with wp_the_query - "recent entries" widget is still loop-breaking
#12
@
17 years ago
- Resolution → fixed
- Status assigned → closed
The Recent Posts widget already uses this technique (albeit in a less hackish way).
#14
@
17 years ago
Nothing is changing wp_the_query. When reset_query is run, then the wp_query is removed and then recreated with what is in wp_the_query. If you are running into problems, then it isn't in anything in the Widget but code outside of it.
#17
@
17 years ago
had not occurred, even. there is *major* bug in wp_reset_query atm. try the procedure I outline above and see for yourself. It *wrecks* everything. insert the recent posts before calling the_content(), you'll see the post's contents turned into the recent widget's last items' contents.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
broken patch