ThemeForest

wp_list_categories how to alter it?

807 posts
  • Sold between 250 000 and 1 000 000 dollars
  • Elite Author
  • Won a Competition
  • Exclusive Author
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Europe
  • Bought between 10 and 49 items
+2 more
mixey says

Hi guys,

How can I alter what outputs wp_list_categories? I’m need to put some menu items under particular category and those are simple links, not links to actual categories.

I suppose I’ll need to deal with add_filter but I haven’t worked with it before any help is greatly appreciated.

Thanks! Michael

60 posts
  • Bolivia
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 50 and 99 users
Slimmity says

Hi mixey your best option for this is using the Walker Class, it might be complicated but i don’t see any other way of doing this. Read this post http://www.wprecipes.com/how-to-modify-lists-like-categories-and-blogroll-in-wordpress it should explain or at least guide you a bit

415 posts
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Has been a member for 4-5 years
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Portugal
unisphere says

See if that function supports a parameter to not echo output (“echo=0” maybe) and store it in an array, then parse it adding your custom code.

EDIT : Try this


$cats = wp_list_categories('echo=0&title_li=');  
$cats = explode("", $cats);  

foreach($cats as $cat) {  
...
}  

You might need some debugging here to see what value $cat has but it may actually work.

by
by
by
by
by