The archive.php of easel and comicpress has a serious memory hog issue and with some help from Trump http://goatmouf.net I was able to find it and figure out a fix for it.

Basically what I was doing in the archive.php to find a ‘total count’ of how many finds was to actually do another query and grab the count that way, which essentially just basically doubled the amount of memory used for the finding of information -> BAD frumph BAD.

So in the archive.php find this:

Protect();
$tmp_search = new WP_Query($query_string.'&showposts=-1&posts_per_page=-1');
if (isset($tmp_search->post_count)) {
	$count = $tmp_search->post_count;
} else {
	$count = "No";
}
$tmp_search = null;

UnProtect();

or something relatively like that, and comment it out or delete that whole section.

/*
Protect();
$tmp_search = new WP_Query($query_string.'&showposts=-1&posts_per_page=-1');
if (isset($tmp_search->post_count)) {
	$count = $tmp_search->post_count;
} else {
	$count = "No";
}
$tmp_search = null;

UnProtect();
*/

The /* and */ act as “comment everything between this.

Then under that, we need to place

$count = "No";

That would be placed right above the if (have_posts()):

$count = "No";
if (have_posts()) :

Now we still want to “count” the amount of found posts, we need to add the info to get the #

$count = "No";
if (have_posts()) :
	$count = $wp_query->found_posts;

This will allow the $count to be populated with the correct value of all the posts that were found. Now for the bad news, its not tested with *every* scenario yet, so we cant be totally sure that all counts will be completely 100% accurate, but it will definitely save a ton of memory when someone goes into the archives.

Comments

comments