Title: [Plugin: Random Posts Within Date Range Widget] Required secondary loop
Last modified: August 19, 2016

---

# [Plugin: Random Posts Within Date Range Widget] Required secondary loop

 *  [mjdigital](https://wordpress.org/support/users/mjdigital/)
 * (@mjdigital)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-random-posts-within-date-range-widget-required-secondary-loop/)
 * Just a quicky to say the plugin is great but when used on pages with other plugins
   using extra loops/modified posts (like an events calendar) the widget was showing
   the main page content rather than the required posts.
 * I fixed this by altering the query to use get_posts rather than WP_Query – basically
   I edited the following lines in random-posts-within-date-range-widget.php (v1.2):
 *     ```
       Line 289: added - global $post;
       Line 290: was - while($posts->have_posts() ){
                 to  - foreach($posts as $post){
       Line 291: was - $posts->the_post();
                 to  - setup_postdata($post);
       Line 421: was - $posts = new WP_Query($query);
                 to  - $posts=get_posts($query);
       ```
   
 * Not sure if it will help anyone else but it made a difference to me.
 * Thanks for a great plugin.
 * [http://wordpress.org/extend/plugins/random-posts-within-date-range-widget/](http://wordpress.org/extend/plugins/random-posts-within-date-range-widget/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [lupka](https://wordpress.org/support/users/lupka/)
 * (@lupka)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-random-posts-within-date-range-widget-required-secondary-loop/#post-1924330)
 * Thanks for pointing that out. I’ll look into that bug when I get a chance.

Viewing 1 replies (of 1 total)

The topic ‘[Plugin: Random Posts Within Date Range Widget] Required secondary loop’
is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/random-posts-within-date-range-widget.
   svg)
 * [Random Posts Within Date Range Widget](https://wordpress.org/plugins/random-posts-within-date-range-widget/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/random-posts-within-date-range-widget/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/random-posts-within-date-range-widget/)
 * [Active Topics](https://wordpress.org/support/plugin/random-posts-within-date-range-widget/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/random-posts-within-date-range-widget/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/random-posts-within-date-range-widget/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [lupka](https://wordpress.org/support/users/lupka/)
 * Last activity: [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-random-posts-within-date-range-widget-required-secondary-loop/#post-1924330)
 * Status: not a support question