current_category not working
-
AAAUUUGGGHHH!!!!! I’ve been staring at this for hours!
I’m using an adapted version of the MassivePress theme, trying to add a different style for the current category in my widgetized list of categories. Should be easy, right?
For some reason, my code is not getting “current-cat” inserted into the li class as it should. How do I troubleshoot this? I have been through category-template.php and classes.php and nothing looks out of place to me.
Thank you for your help!
Here’s my code from catgeory-template.php
function wp_list_categories( $args = ” ) {
$defaults = array(
‘show_option_all’ => ”, ‘orderby’ => ‘name’,
‘order’ => ‘ASC’, ‘show_last_update’ => 0,
‘style’ => ‘list’, ‘show_count’ => 0,
‘hide_empty’ => 1, ‘use_desc_for_title’ => 1,
‘child_of’ => 0, ‘feed’ => ”, ‘feed_type’ => ”,
‘feed_image’ => ”, ‘exclude’ => ”, ‘exclude_tree’ => ”, ‘current_category’ => 0,
‘hierarchical’ => true, ‘title_li’ => __( ‘Categories’ ),
‘echo’ => 1, ‘depth’ => 0`And in $output = ”…
if ( empty( $r['current_category'] ) && is_category() ) $r['current_category'] = $wp_query->get_queried_object_id();In classes.php under function start_el() I have…
if ( isset($current_category) && $current_category ) $_current_category = get_category( $current_category ); if ( 'list' == $args['style'] ) { $output .= "\t<li"; $class = 'cat-item cat-item-'.$category->term_id; if ( isset($current_category) && $current_category && ($category->term_id == $current_category) ) $class .= ' current-cat'; elseif ( isset($_current_category) && $_current_category && ($category->term_id == $_current_category->parent) ) $class .= ' current-cat-parent'; $output .= ' class="'.$class.'"'; $output .= ">$link\n"; } else { $output .= "\t$link<br />\n"; } }
The topic ‘current_category not working’ is closed to new replies.