I have been researching this for a while. I am trying to make most of my WP theme ignore posts of two categories (C1, C2). Using several techniques I am able to do this for most content.
But I still have a problem with getting the standard Archives widget to omit the Posts with the excluded categories, as returned by wp_get_archives. The best technique seemed to be the customized functions.php technique described at:
which sets up:
add_filter( ‘getarchives_where’, ‘customarchives_where’ );
add_filter( ‘getarchives_join’, ‘customarchives_join’ );
This actually does work at eliminating the Posts with the excluded categories.
But there is a problem with this code — the additional JOINS cause the resulting query to return one record PER CATEGORY when there are posts under multiple categories. That causes the Post-Count numbers to be incorrect in the widget display, showing numbers that are too big (the # post-categories, not the # posts).
Anyone have an idea how this SQL can be adjusted to return the right # records — 1 per post — even when posts have multiple categories?
- The topic ‘Excluding categories from wp_get_archives’ is closed to new replies.