Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • I agree, joshua4. This is how I ended up solving my problem. It’s inelegant, but it works.

    If you, like me, want to limit get_categories to a depth of one, you can do this:

    <?php global $ancestor; // Declare global ancestor variable ?>
    <?php foreach ($categories as $cat) {
    	if ($cat->cat_ID != 1) { // If category is not uncategorized ...
    	if (cat_is_ancestor_of($ancestor, intval($cat->cat_ID)) == false) { // .. and if the previous category in the loop wasn't the ancestor of this one ... ?>
    		<h2><a href="<?php echo get_category_link($cat->cat_ID); ?>"><?php echo ($cat->cat_name); ?></a></h2>
    		<?php echo ( category_description($cat->cat_ID) );  ?>
    
    		<?php
    		$ancestor = intval($cat->cat_ID); }; // make this category the new ancestor
    		};
    	};
    ?>

    If you want to limit depth to two (like displayname does above), you could declare a global $grandparent variable, then at the end of the loop, make the former $ancestor the new $grandparent and the current category the new $ancestor. Then just add another $greatgrandparent if you want a depth of three levels, and so on and so on.

    This is a mighty hacky way of just getting depth for get_categories. I think I’ll submit a ticket for that.

    I’m having this same problem. Wp_list_categories doesn’t give me the flexibility I need, because I can’t seem to display both title and description with that function. But I need to be able to limit depth with get_categories.

    Does anyone have ideas on how I might be able to write a wrapper function around get_categories that would allow me to display subcategories to only one depth?

    Thanks in advance for your help.

    Thread Starter mthomps

    (@mthomps)

    I’m using Firefox 1.5 also, and I’ve tried it in IE as well. I should mention that when I upload an image and just click “Browse,” it shows only the image that I uploaded and works fine. But when I click “Browse All,” it’s broken; clicking on the thumbnails does nothing.

    Thanks very much for your help with this. It has me baffled.

    Thread Starter mthomps

    (@mthomps)

    I’ve used them before. I’ve been testing out different plugins for uploading and dealing with media, so I’ve posted several entries using different plugins. The native uploader had been the most stable one so far, and it was the one I was testing when it suddenly stopped working. At that time, the other plugins I had activated were ImageManager, Akismet, and Audio player.

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