0

Is it possible to do this? In the codex the 'orderby' option does not allow manual ordering (only ascending ID, name, count, slug etc).

Here is the code:

<?php
    wp_list_categories('include=16,17,15&title_li=<h3>' . __('By Content') . '</h3>' ); 
?>

This is currently alphabetical since I havent included the 'orderby' statement. I want them ordered 17,15,16 but only these 3 cats which are not alphabetical.

Is this possible?

1

1 Answer 1

0

I would use get_categories() to first get an associative array of all the categories and then sort it how you want it.

$categories = get_categories('include=16,17,15');
4
  • Thanks for the reply, replaced my code with your suggestion and it disappears completely.
    – buksida
    Commented Jun 11, 2015 at 9:48
  • Maybe read up on the docs (that I even linked). It doesn't print out the categories as a link but instead returns an array. You then have to sort it with a comparison function and then write a loop (maybe foreach) that will print the list. The PHP docs will help you. Commented Jun 11, 2015 at 13:21
  • Thanks, read those already before posting, seems like it isnt possible without a bunch of complex coding which is beyond me.
    – buksida
    Commented Jun 13, 2015 at 0:19
  • Yes, I don't know about a way to do this with Wordpress alone. But it's not that hard to write a solution in PHP. And it's always good to know PHP when developing Wordpress Themes. Commented Jun 15, 2015 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.