Support » Fixing WordPress » Category Parent/Child Issues

  • This one is really confusing me. I use the following piece of code to determine the category.

    $category = 1;
    foreach((get_the_category()) as $cat) {
       $cats =  $cat->cat_name . ' ';   if(strstr("$cats", "Free Traffic Systems")  != FALSE) {
    	$rated_services = true;
       } else {
    	$category = $cat;

    This is called out in the open, outside the_loop in category.php

    The way that it should work would be to find all the categories that we’re trying to look at and if it has a child, to favor the child over the parent.

    It works flawlessly for the children… but the parents seem to be assigned to a child no matter what.

    Let me give you an example. My site: has several different categories. Free Traffic Systems has several child categories. When I publish a post I put it in both the parent and child. So the category “Free Traffic Systems” should include posts from “Banner Exchanges”, “Safelists”, “Traffic Exchanges” and “Viral Marketing”

    However, the actual result is that by viewing “Free Traffic Systems” you see the contents of “Safelists”… which is obviously not the intended result.

    I really can’t figure out why it’s doing this. Are there better ways to determine the category of an individual category page? and to favor the child? Any help/advice you could give would be greatly appreciated.


  • The topic ‘Category Parent/Child Issues’ is closed to new replies.