Posts Per Page Plugin Spitting Back Blank Page After Upgrade to 1.5.1.2
-
Hey All,
As the title says… It worked fine in 1.5.1.1, however after upgrading, I’m getting that pesky blank page error.
I got this plugin from Ian, however, I think he may have missed my previous post about this in another part of the forum.
Here’s the code:
<?php
/*
Plugin Name: Custom Posts Per Page
Version: 1.0
Plugin URI: https://www.ads-software.com/support/6/11211
Description: Change the number of posts per page displayed for different page types.
Author: Based on code by rboren & brehaut
Author URI:
*/
$posts_per[‘home’] = 5;
$posts_per[‘day’] = 10;
$posts_per[‘month’] = 31;
$posts_per[‘search’] = 10;
$posts_per[‘year’] = 999;
$posts_per[‘author’] = 999;
$posts_per[‘category’] = 999;
function custom_posts_per_page($query_string) {
global $posts_per;
$query = new WP_Query();
$query->parse_query($query_string);
if ($query->is_home) {
if (preg_match(“/posts_per_page=/”, $query_string)) {
$query_string = preg_replace(“/posts_per_page=[0-9]*/”
,”posts_per_page=$num_posts_on_home”
,$query_string);
} else {
if ($query_string != ”) {
$query_string .= ‘&’;
}
$query_string .= “posts_per_page=$num_posts_on_home”;
}
}
} elseif ($query->is_day) {
$num = $posts_per[‘day’].’&order=ASC’;
} elseif ($query->is_month) {
$num = $posts_per[‘month’].’&order=ASC’;
} elseif ($query->is_year) {
$num = $posts_per[‘year’].’&order=ASC’;
} elseif ($query->is_author) {
$num = $posts_per[‘author’];
} elseif ($query->is_category) {
$num = $posts_per[‘category’];
} elseif ($query->is_search) {
$num = $posts_per[‘search’];
}
if (isset($num)) {
if (preg_match(“/posts_per_page=/”, $query_string)) {
$query_string = preg_replace(“/posts_per_page=[0-9]*/”, “posts_per_page=$num”, $query_string);
} else {
if ($query_string != ”) {
$query_string .= ‘&’;
}
$query_string .= “posts_per_page=$num”;
}
}
return $query_string;
}
add_filter(‘query_string’, ‘custom_posts_per_page’);
?>Thanks,
Justin
- The topic ‘Posts Per Page Plugin Spitting Back Blank Page After Upgrade to 1.5.1.2’ is closed to new replies.