837 posts
  • Power Elite Author: Sold more than $1M on Envato Market
  • Won a competition
  • Made it to the Authors' Hall of Fame
  • Has sold $2M+ on Envato Market
+7 more

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
  • Has been part of the Envato Community for over 6 years
  • Has referred 50+ members
  • Located in Bolivia, Plurinational State of
  • Has collected 10+ items on Envato Market
+1 more

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
  • Has referred 10+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 more

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.

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes