get_category($cat) returns NULL in widget
-
Hello,
I’ve been using the following code in a sidebar without any problems;
<?php if (is_front_page() || !is_single() || is_category()) : $this_category = get_category($cat); echo"<li><h3>Sub Categories</h3>"; echo"<ul>"; wp_list_categories('orderby=order&show_count=1&depth=1&title_li=&use_desc_for_title=1&child_of='.$this_category2->cat_ID); echo"</ul></li>"; endif; ?>
Works perfectly thanks to the advice on the forums.
However if I move the code to a Widget which has PHP parsing enabled (have tried different plugins for this) everything works except
get_category($cat)
which does not return the current category ID, just null ?Any ideas how to get this working in a widget ?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘get_category($cat) returns NULL in widget’ is closed to new replies.