[wp-testers] Highlight current category...

Ryan Boren ryan at boren.nu
Thu Oct 27 23:13:22 GMT 2005


On Fri, 2005-10-28 at 10:55 +1300, Amanzimtoti wrote:
> I'm not really a php coder, but I recently made a change to the
> list_cats function within the
> wp-includes/templates-functions-category.php file which enables the
> current category to be highlighted if you're on a category page. I
> noticed that this was one of the features requests on the 1.6 codex
> page so thought that you guys may be interested in this. If there's a
> more elegant way to do this, please let me know.

We do something similar with pages.  Try code like this:

$queried_obj_id = $wp_query->get_queried_object_id();

if ( $category->cat_ID == $queried_obj_id )
	$link = '<a href="'.get_category_link($category->cat_ID).'"
class="current-cat" ';


See _page_level_out() in template-functions-post.php.

Ryan




More information about the wp-testers mailing list