<?php
/*
Plugin Name: Kinderlose
Plugin URI: http://guff.szub.net/kinderlose
Description: Remove posts from child categories in (parent) category queries.
Version: R1.1
Author: Kaf Oseo
Author URI: http://szub.net
Copyright (c) 2007-2008, 2011 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 3.1 plugin (http://wordpress.org).
Inspired by Just One Category (Michael Adams) and No SubCats (Rich Hamilton).
~Changelog:
R1.1 (May-29-2011)
Regex change to get things working with latest/greatest (WP 3.1.x).
R1.0.1 (Jan-09-2008)
Fix to regex replacing 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_taxonomy_id IN \((.*)\)/U', '.term_taxonomy_id IN (\'' . $wp_query->query_vars['cat'] . '\')', $where);
}
return $where;
}
add_filter('posts_where', 'kinderlose_where');
?>