View Single Post
Old 11-10-2012, 08:43 AM  
LucyVanAngel
Confirmed User
 
Join Date: Mar 2009
Posts: 305
wordpress - php question

hi, one of my blogs is running too slow because of the amount of posts (over 5000)
the index.php file of wp has the following code:

#########
<?php if(have_posts()) { ?>
<?php while (have_posts()) : the_post(); ?>
#########

The have_posts() function is defined as follows:
############
./wp-includes/query.php: function have_posts() {
if ( $this->current_post + 1 < $this->post_count ) {
return true;
} elseif ( $this->current_post + 1 == $this->post_count && $this->post_count > 0 ) {
do_action_ref_array('loop_end', array(&$this));
// Do some cleaning up after the loop
$this->rewind_posts();
}

$this->in_the_loop = false;
return false;
}
#####################

Wordpress is returning EVERY single post (5000) in the database and then iterating over them performing a SQL query for each.
It does not help changing the theme because that routine is in wp itself not in the theme.

Anybody help ?

thanks
LucyVanAngel is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook