Ryan Boren’s Category Excluder Plugin Troubleshooting
-
Trying to exclude a category from the front (index.php) page in the official 1.5 (can’t remember those musicians).
Tried the 1.5 and the 1.2 index.php hacks (I’m running in the default setup – with only one index.php so root errors not applicable). The 1.5 locked up the site (blank screen) and the 1.2 didn’t do anything. I understand that ‘Kitty’s’ plugin doesn’t work with 1.5, but Ryan Boren’s is tops. Got the Dec. 17 (’04) initial edition off the coldforge site, and it doesn’t seem to work either.
I have 24 categories (about 5 mains and the rest subs). Looking to exclude one of the mains, #24. Customized script is below. (Pasted the text script into a PHP template in Dreamweaver to create the php). Activated it in the Plugins and let ‘er rip. Home page came up but it didn’t block the category (or any other). Has anyone worked with this or other hacks to hide cats in 1.5? -Really like to hear from you. (Just noticed the 8859 encoding – will try changing it to UTF(8) but not sure if it’ll matter, so am posting this anyway).<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
</head><body>
<?php
/*
Plugin Name: Front Page Categories
Version: 0.2
Plugin URI: http://wordpress.org/#
Description: Select categories to display on the front page.
Author: Ryan Boren
*/function fpc_where($where) {
// Change this to the categories you want to show on the front page.
// Example: $cats_to_show = ‘1 2 3 4’;
$cats_to_show = ‘1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23’;global $wpdb, $wp_query;
if (! $wp_query->is_home) {
return $where;
}$cat = $cats_to_show;
if (stristr($cat,’-‘)) {
// Note: if we have a negative, we ignore all the positives. It must
// always mean ‘everything /except/ this one’. We should be able to do
// multiple negatives but we don’t 🙁
$eq = ‘!=’;
$andor = ‘AND’;
$cat = explode(‘-‘,$q[‘cat’]);
$cat = intval($cat[1]);
} else {
$eq = ‘=’;
$andor = ‘OR’;
}$cat_array = explode(‘ ‘, $cat);
$whichcat .= ‘ AND (category_id ‘.$eq.’ ‘.intval($cat_array[0]);
$whichcat .= get_category_children($cat_array[0], ‘ ‘.$andor.’ category_id ‘.$eq.’ ‘);
for ($i = 1; $i < (count($cat_array)); $i = $i + 1) {
$whichcat .= ‘ ‘.$andor.’ category_id ‘.$eq.’ ‘.intval($cat_array[$i]);
$whichcat .= get_category_children($cat_array[$i], ‘ ‘.$andor.’ category_id ‘.$eq.’ ‘);
}
$whichcat .= ‘)’;$where .= $whichcat;
return $where;
}function fpc_join($join) {
global $wpdb, $wp_query;if (! $wp_query->is_home) {
return $join;
}$join .= ” LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) “;
return $join;
}add_filter(‘posts_join’, ‘fpc_join’);
add_filter(‘posts_where’, ‘fpc_where’);?>
</body>
</html>
- The topic ‘Ryan Boren’s Category Excluder Plugin Troubleshooting’ is closed to new replies.