searlaitm Posted November 29, 2007 Posted November 29, 2007 Hello, I'm tweaking my blog and have run into a problem. In the header, the categories sort themselves by name or rather alphabetically. <ul> <?php wp_list_categories('sort_column=name&exclude=55,56 ,57,58&title_li=&depth=1'); ?> </ul> I have been able to exclude the categories, which I don't want and happy that that works, but I can't understand what to do? If I write ('sort_column=id&exclude=55,56,57,58&title_li=&dep th=1'); then my categories will still remain in alphabetical order AND one of the categories sometimes drops out. I have consulted Wordpress Codex but I can't figure it out. I did try to write ('include=1,2,3,4&exclude=55,56,57,58&title_li=&de pth=1'); but that hasn't worked either. I have been recommended to using a '$mylist=news,environment,arctic' but I can't find a "$mylist " code in my header. So does anyone have any idea how sort the categories so that they do not get ordered alphabetically? /C Quote
joefish Posted November 29, 2007 Posted November 29, 2007 The template tag wp_list_categories() is a fairly recent function, one that's intended to replace the older wp_list_cats(). Both functions work in a very similar way. One problem I can see is that you're using arguments intended for wp_list_cats() with wp_list_categories() instead. To sort by id with wp_list_cats: ><?php wp_list_cats('sort_column=id'); ?> To sort by id with wp_list_categories: ><?php wp_list_categories('orderby=id'); ?> What's that `depth=1` argument you're using? I can't find any documentation on that for either function. What's your intended effect? A flat list, instead of nests for subcategories? Quote
searlaitm Posted November 29, 2007 Author Posted November 29, 2007 (edited) The template tag wp_list_categories() is a fairly recent function, one that's intended to replace the older wp_list_cats(). Both functions work in a very similar way. One problem I can see is that you're using arguments intended for wp_list_cats() with wp_list_categories() instead. To sort by id with wp_list_cats: ><?php wp_list_cats('sort_column=id'); ?> To sort by id with wp_list_categories: ><?php wp_list_categories('orderby=id'); ?> What's that `depth=1` argument you're using? I can't find any documentation on that for either function. What's your intended effect? A flat list, instead of nests for subcategories? I have tried ><?php wp_list_categories('orderby=id'); ?> but for some weird reason they haven't changed, might be my cache though???? I'll go ahead and try once more. You're absolutely correct, it's a flat list, though I'll admit that this theme was purchased and I'm learning by doing and tweaking, rather than composing it myself. I did remove it at first and IMHO it looks a whole lot better being flat-listed. Edited November 29, 2007 by searlaitm Quote
joefish Posted November 29, 2007 Posted November 29, 2007 Looking at what you have in your first post, it seems like something like... ><?php wp_list_categories('orderby=id&exclude=55,56,57,58&title_li=&hierarchical=0'); ?> ...would generate what you're looking for. Order by ID, exclude the specified categories, no heading or outer list item, no nested lists for subcategories. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.