﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
12320	Invalid call to wp_reset_query() inside Recent Posts widget	michelwppi	azaozz	"'''Description:'''

When adding Recent posts widget in sidebar of a home page modified by a '''query_posts''' limiting to one cat. or other features, the loop result of posts is not the attended one but the original default home query.

The ''recent posts widget'' in defaut-widgets.php contains a curious line:

{{{
wp_reset_query();  // Restore global post data stomped by the_post().
}}}

The Query.php contains this function with his ""obscure"" comment:

{{{
/**
 * Destroy the previous query and setup a new query.
 *
 * This should be used after {@link query_posts()} and before another {@link
 * query_posts()}. This will remove obscure bugs that occur when the previous
 * wp_query object is not destroyed properly before another is setup.
 *
 * @since 2.3.0
 * @uses $wp_query
 */
function wp_reset_query() {
}}}

With this resetting approach and - not with temporay backup and restore - when, in loop in loop, sharing global vars as $wp_query or $wp_the_query, it introduces unwanted side effects.

'''Temporary workaround:'''
Around the ''sidebar top'' box, needs to add these temp vars:

{{{
global $wp_the_query, $wp_query;
$tmp_query = $wp_query;
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar top')) : ?>
<ul>
 	<li>?</li>
</ul>
<?php  endif; $wp_the_query = $tmp_query;  $wp_query = $tmp_query;

}}}
with the limit of only one ''recent posts'' widget in one sidebar box.

Don't hesitate to question me.

NOTE: In our [http://dev.xiligroup.com/xili-language/] plugin, we decide to create a new like widget without this 'obscur' reset function ''wp_reset_query'' and added of other features for multilingual website.

Best regards, Michel of  [http://dev.xiligroup.com]


"	defect (bug)	closed	normal	3.0	Widgets	2.9.2	normal	fixed	has-patch commit	michelwppi
