Hello,
I need a quick answer so posting this question - very simple but I don't know how to sort it :/
I'm using <strong>wp_list_categories</strong> for a side bar. But i'm using iScroll and it does not like nested lists.
I need my markup to look like this...
<ul>
<li>Categories</li>
<li><a href="news">News</a></li>
<li><a href="uncategorized">Uncategorized</a></li>
</ul>
But instead it looks like this...
<ul>
<li>Categories</li>
<li>
<ul>
<li><a href="news">News</a></li>
<li><a href="uncategorized">Uncategorized</a></li>
</ul>
</li>
</ul>
How can I format <strong>wp_list_categories</strong> so it formats similar to <strong>wp_list_cats</strong>?
This wp_list_cats function formats correctly as a un-nested list (see below) - but I would rather not use a deprecated function?
<ul>
<li class="sidebar-title">Contents</li>
<?php wp_list_cats('show_count=1'); ?>
</ul>
Thanks Josh
Francisco Javier Carazo Gil answers:
Hi Josh,
You want depth = 1:
<?php wp_list_categories('title_li=&hierarchical=0&depth=1');?>
Josh Cranwell comments:
Thank you - worked!
Julio Potier answers:
Hello
<em>wp_list_categories()</em> can take arguments, try this :
wp_list_categories( array( 'title_li' => '' ) );
See you !
Josh Cranwell comments:
Thank you - worked too!
Pau answers:
use get_the_category_list instead: http://codex.wordpress.org/Function_Reference/get_the_category_list
Josh Cranwell comments:
will check it out thanks
Romel Apuya answers:
use depth -1
<?php wp_list_categories('depth= -1');?>
or hierarchical=0
<?php wp_list_categories('hierarchical=0');?>
Josh Cranwell comments:
tried both on their own - still nested the list inside a list. Thanks anyway dude