Make WordPress Core

Opened 18 years ago

Closed 17 years ago

Last modified 17 years ago

#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)

widgets.patch (638 bytes ) - added by msi08 18 years ago.

Download all attachments as: .zip

Change History (21)

@msi08
18 years ago

#1 @Denis-de-Bernardy
17 years ago

  • Component GeneralWidgets
  • Keywords has-patch 2nd-opinion added
  • Milestone 2.92.8
  • Owner anonymous removed
  • Version2.7

#2 @Denis-de-Bernardy
17 years ago

  • Keywords needs-patch added; has-patch removed
  • Milestone 2.8Future Release

broken patch

#3 @Denis-de-Bernardy
17 years ago

  • Milestone Future Release
  • Resolutioninvalid
  • Status newclosed

invalid, given how wp_reset_query() behaves

#4 @Denis-de-Bernardy
17 years ago

  • Milestone2.8
  • Resolution invalid
  • Status closedreopened

annoyingly, I just ran into this one myself.

#5 @Denis-de-Bernardy
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

#6 @Denis-de-Bernardy
17 years ago

something in there is changing wp_the_query.

#7 @Denis-de-Bernardy
17 years ago

  • Owner set to Denis-de-Bernardy
  • Status reopenedassigned

it's occurring around the_post(), but I can't figure out what it might be.

#8 @Denis-de-Bernardy
17 years ago

  • Component WidgetsQuery

#9 @Denis-de-Bernardy
17 years ago

  • Summary "recent entries" widget is still loop-breakingthe_post() called on an arbitrary query messes around with wp_the_query - "recent entries" widget is still loop-breaking

#10 @Denis-de-Bernardy
17 years ago

  • Summary the_post() called on an arbitrary query messes around with wp_the_query - "recent entries" widget is still loop-breakinga 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 @jacobsantos
17 years ago

  • Resolutionfixed
  • Status assignedclosed

The Recent Posts widget already uses this technique (albeit in a less hackish way).

#13 @jacobsantos
17 years ago

If there is still a problem, then it is not where you expect it to be.

#14 @jacobsantos
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.

#15 @Denis-de-Bernardy
17 years ago

  • Resolution fixed
  • Status closedreopened

#16 @Denis-de-Bernardy
17 years ago

Jacob, I wouldn't have opened the ticket if it had occurred in trunk. ;-)

#17 @Denis-de-Bernardy
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.

#18 @Denis-de-Bernardy
17 years ago

also, consider adding this after the call to the_post() in the recent posts widget:

var_dump($GLOBALS['wp_the_query']->post->ID);

you will notice that it changes.

#19 @Denis-de-Bernardy
17 years ago

  • Resolutionduplicate
  • Status reopenedclosed

merging this into #9854

#20 @Denis-de-Bernardy
17 years ago

  • Milestone 2.8
Note: See TracTickets for help on using tickets.