[wp-hackers] Filtering of posts

David Clark david at davidsaccess.com
Wed Oct 13 16:53:38 UTC 2004


Hi,

I have been confused for a while as to you there is no api to exclude 
post categories in the same way as you can exclude links.

I do know about Kitty''s show categories plugin, and have used it as a 
basis for what I needed to do http://www.davidsaccess.com/archive.php. 
the problem I had is that it created a new array $hcp_posts, rather 
than filtering pust.

I took show categories, along with get_links, as modes and created

function exclude_clause() {	
	global $exclude_post_cats;
	$exclusions = '';
	if (!empty($exclude_post_cats)) {
		$excats = preg_split('/[\s,]+/',$exclude_post_cats);
		if (count($excats)) {
			foreach ($excats as $excat) {
				$exclusions .= ' AND category_id <> ' . intval($excat) . ' ';
			}
		}
	return $exclusions;
	}
}

What would be the downside to  adding $exclusions to the original sql 
that instantiates $posts?

Am I just showing another example of my cluelessness here? :)


dc




More information about the hackers mailing list