Ticket #5439: reset_query.diff

File reset_query.diff, 831 bytes (added by ryan, 4 years ago)
  • wp-includes/query.php

     
    2525function wp_reset_query() { 
    2626        unset($GLOBALS['wp_query']); 
    2727        $GLOBALS['wp_query'] =& $GLOBALS['wp_the_query']; 
     28        if ( !empty($wp_query->post) ) { 
     29                $GLOBALS['post'] = $wp_query->post; 
     30                setup_postdata($wp_query->post); 
     31        } 
    2832} 
    2933 
    3034/* 
  • wp-includes/widgets.php

     
    874874                        </ul> 
    875875                <?php echo $after_widget; ?> 
    876876<?php 
     877                wp_reset_query();  // Restore global post data stomped by the_post(). 
    877878        endif; 
    878879        wp_cache_add('widget_recent_entries', ob_get_flush()); 
    879880}