Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter slidese

    (@slidese)

    The request is ?cat=2, and this code does the trick.


    $cat_shown = array();
    foreach ($category_cache as $cat_array) {
    foreach ($cat_array as $the_category) {
    $the_ID = $the_category->cat_ID;
    if (in_array($the_ID, $cat_shown))
    continue;
    $cat_shown[] = $the_ID;
    echo $the_category->cat_name;
    echo "<br>\n";
    }
    }

    And use $posts to get all posts from cat=2 and sub-categories.

    Mike

    Thread Starter slidese

    (@slidese)

    Thanks, but I’m developing a theme and would like to incorporate this feature as a standard.

    Is this really that hard to program using a WP_Query or The Loop (in some way)?

    If I click a category (ie, ?cat=3), how do I “get” that var? Is the only way to get it through $_GET? And after that, constructing a query that gives me all subcategories of that one, and for each of those, give me all posts.

    Does anyone have any ideas about doing that?

    Mike

Viewing 2 replies - 1 through 2 (of 2 total)