No Subcategory Posts in Parent hack
-
This is so basic it cannot really be called a hack, and it may be someone has already pointed it out though I don’t think so. Some people, including myself, have wanted to prevent subcateory posts appearing in the parent category listing. I messed with this for hours yesterday before finding this. It works for me, I cannot say it is fully tested.
Go to around line 265 in wp_blog_header.php, find the following lines and put /* the code snippet below */ around it.
$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.' ');
}
That?¢??s it, no more subcategory posts appearing in the main category post listing. You can see it in action in my journal.
https://www.andrew-hall-artist.com/journal/
Andrew
- The topic ‘No Subcategory Posts in Parent hack’ is closed to new replies.