• Hi,

    As part of customising the way categories are displayed in my sidebar, I need to be able to display just the first 3 categories, ordered alphabetically (ascending) & show the number of posts for each of these categories.

    Having read through the codex, the best thing I’ve been able to come up with is:

    <?php WP_list_cats (‘ sort_column=name&optioncount=1&exclude=x’);?>
    where x=the list of category ids I want to exclude

    Although this will work, I have a long list of categories that need to be excluded, so it’s a bit clumsy, added to which, everytime I add a category, I’ll have to alter the code.

    What I really want is to be able to say exclude x where where x=all categories with ids greater than 3, but my limited understanding of the syntax for this function tell me I can’t do this…or can I?

    Can anyone suggest an elegant solution?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • How are you with PHP?

    If you are familiar and comfortable with programming in PHP, what you could do is use the list_cats function with recurse setting set to TRUE which would return the list, and then use to PHP to remove all categories that you do not need, and display the rest

    Cannot think of a more ‘elegant’ way right now .. let me know if that works, if it doesn’t I can try see if something else is possible.

    Thread Starter newbee

    (@newbee)

    Thanks, but I am neither familiar nor comfortable with PHP.

    That is not so good .. ??

    In that case I am afraid I don’t see any other methods of doing what you want, with builtin WP functions ..

    Maybe someone else can clarify this, but I think custom code is the only way you are going to achieve what you want.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Help Needed Customising ‘Categories’ Function’ is closed to new replies.