Skip to content

Commit

Permalink
Switch to get_posts for recent dropdown since it has a lower overhead…
Browse files Browse the repository at this point in the history
… than WP_Query. Prevents out-of-memory issues in some instances.
  • Loading branch information
mjangda committed Dec 31, 2012
1 parent ab43f95 commit b27fd42
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions zoninator.php
Expand Up @@ -505,16 +505,16 @@ function zone_admin_recent_posts_dropdown( $zone_id ) {
'post__not_in' => $zone_post_ids, 'post__not_in' => $zone_post_ids,
) ); ) );


$latest_query = new WP_Query( $args ); $recent_posts = get_posts( $args );
?> ?>
<div class="zone-search-wrapper"> <div class="zone-search-wrapper">
<label for="zone-post-search-latest"><?php _e( 'Add Recent Content', 'zoninator' );?></label><br /> <label for="zone-post-search-latest"><?php _e( 'Add Recent Content', 'zoninator' );?></label><br />
<select name="search-posts" id="zone-post-latest"> <select name="search-posts" id="zone-post-latest">
<option value="">Choose latest post</option> <option value="">Choose latest post</option>
<?php <?php
while ( $latest_query->have_posts() ) : $latest_query->the_post(); foreach ( $recent_posts as $post ) :
echo sprintf( '<option value="%d">%s</option>', get_the_ID(), get_the_title() ); echo sprintf( '<option value="%d">%s</option>', $post->ID, get_the_title( $post->ID ) );
endwhile; endforeach;
wp_reset_postdata(); wp_reset_postdata();
?> ?>
</select> </select>
Expand Down

0 comments on commit b27fd42

Please sign in to comment.