Permalink
Browse files

Switch to get_posts for recent dropdown since it has a lower overhead…

… than WP_Query. Prevents out-of-memory issues in some instances.
  • Loading branch information...
1 parent ab43f95 commit b27fd427bcf34f96fb6d7fbff71f2fa9cb03bdcf @mjangda mjangda committed Dec 31, 2012
Showing with 4 additions and 4 deletions.
  1. +4 −4 zoninator.php
View
@@ -505,16 +505,16 @@ function zone_admin_recent_posts_dropdown( $zone_id ) {
'post__not_in' => $zone_post_ids,
) );
- $latest_query = new WP_Query( $args );
+ $recent_posts = get_posts( $args );
?>
<div class="zone-search-wrapper">
<label for="zone-post-search-latest"><?php _e( 'Add Recent Content', 'zoninator' );?></label><br />
<select name="search-posts" id="zone-post-latest">
<option value="">Choose latest post</option>
<?php
- while ( $latest_query->have_posts() ) : $latest_query->the_post();
- echo sprintf( '<option value="%d">%s</option>', get_the_ID(), get_the_title() );
- endwhile;
+ foreach ( $recent_posts as $post ) :
+ echo sprintf( '<option value="%d">%s</option>', $post->ID, get_the_title( $post->ID ) );
+ endforeach;
wp_reset_postdata();
?>
</select>

0 comments on commit b27fd42

Please sign in to comment.