<?php
/*
Plugin Name: Kinderlose
Plugin URI: http://guff.szub.net/kinderlose
Description: Remove posts from child categories in (parent) category queries.
Version: R1.0.1
Author: Kaf Oseo
Author URI: http://szub.net
Copyright (c) 2007, 2008 Kaf Oseo (http://szub.net)
Kinderlose is released under the GNU General Public License, version 2 (GPL2)
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
This is a WordPress 2.3 plugin (http://wordpress.org).
Inspired by Michael D. "mdawaffe" Adams' Just One Category and
Rich Hamilton's No SubCats.
~Changelog:
R1.0.1 (Jan-09-2008)
Fix to the regex replacing the cat IDs; not as greedy now. Thanks to
Kai Ackermann for reporting the bug.
*/
function kinderlose_where($where) {
if ( is_category() ) {
global $wp_query;
$where = preg_replace('/.term_id IN \(\'(.*)\'\)/U', '.term_id IN (\'' . $wp_query->query_vars['cat'] . '\')', $where);
}
return $where;
}
add_filter('posts_where', 'kinderlose_where');
?>