Ticket #5439 (closed defect (bug): worksforme)
page displaying wrong comments
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Template | Version: | 2.3.1 |
| Severity: | normal | Keywords: | comments has-patch widgets 2nd-opinion |
| Cc: |
Description
Depending on how widgets are set up, and the layout of the page, WordPress may display the wrong comments for a post.
The widget.php file uses a variable $id, which is used frequently throughout code. That variable is not unset, and moving the sidebar code above the comment code while this widget is active will cause the comments_template function to instead display comments from the last post on the "recent posts" list. solution proposed.
Attachments
Change History
-
attachment
widgets.php[1].diff
added
Tarski hacks around this issue by adding the following code below the sidebar widgets block, but it would be much better if this weren't necessary.
$wp_the_query->current_post--; setup_postdata($wp_query->next_post());
- Keywords needs-patch added
Patch from 12/07/07 doesn't work for me. Included post reset does fix it, but obviously ideally the widgets code would be better isolated from the page or post loop.
- Keywords has-patch widgets 2nd-opinion added; needs-patch removed
- Component changed from General to Template
Added a patch that seems to fix this.
How about having wp_reset_query() reset the global post data? See patch (untested).
Sorry, been a really busy week. Having just tested this, it doesn't seem to fix my Tarski issue. I commented out the hack I mentioned above, applied the hack, and found all my posts getting the same comments, from the last article on the 'Recent Articles' widget list.
- Status changed from new to closed
- Resolution set to fixed
comment:10
ryan — 4 years ago
comment:11
ryan — 4 years ago
- Status changed from closed to reopened
- Resolution fixed deleted
Using next_post() causes problems with other themes. Reverting and reopening.
comment:12
ionfish — 4 years ago
- Status changed from reopened to closed
- Resolution set to worksforme
- Milestone 2.5 deleted
#6687 has resolved this for me.
comment:13
ionfish — 4 years ago
[6687], rather.

updated proposed fix