Support » Fixing WordPress » Menu Order

  • Resolved randomthoughts

    How can I make the menu list the Catagories in the order that I want them instead of alphabetical?

Viewing 11 replies - 1 through 11 (of 11 total)
  • Edit the category names.
    Putting a space before the name will not affect the look, but it will bump that cat to the top.
    More spaces=higher up.

    Or, if you’re game for playing in MySQL (through phpMyAdmin or equivalent), you can switch the category ids and list them that way (which is default). Just make sure to back up your database before fooling around in there.

    Thread Starter Anonymous

    thanks

    Thread Starter Anonymous

    instead of going into the database, just open up “wp-includes/template-functions-category.php”, and search for “function wp_list_cats”. then change the lines:
    if (!isset($r['sort_column'])) $r['sort_column'] = 'ID';
    if (!isset($r['sort_order'])) $r['sort_order'] = 'asc';

    for sort_column, your options are ID and name, and for sort_order, your options are ‘asc’ (ascending) and ‘desc’ (descending). So, for example, if I wanted my categories displayed in reverse alphabetical order (Z-A) , I’d change those lines to:
    if (!isset($r['sort_column'])) $r['sort_column'] = 'name';
    if (!isset($r['sort_order'])) $r['sort_order'] = 'desc';

    Anon, why go into the code and change things when you can alter the sort order by passing a parameter through wp_list_cats()? See the wiki page on it:
    http://wiki.wordpress.org/wp_list_cats

    Oops, I forgot to include your post suggestion along with podz’. Hard coding might be the best option, though, for when one adds a new category they want higher up the “food chain”.

    Yep.
    I think the answer, finally, is “whatever works for you.”

    Hi,

    I have a static front page http://www.uttoxeter.biz/testsite/ and I want the ‘Pages’ menu list to list in the order of Home, etc, etc, and finish with Contact Us. At the moment it’s alphabetical, not great!

    Could it be a problem naming the Categories the same as the Pages? All pages from the main ‘Pages’ links are static eXtended pages (or will be if they’re not now), where there will be a bit of static text and then a summary of the latest 5 articles with ‘…more’ links to the full article.

    Once I’ve done this, I will remove the categories menu and just have the archives listed under categories.

    This is my first delve into WordPress, blogging, and CMS – and I’m a PHP newbie – so be gentle!

    Any help much appreciated.

    Cheers,

    Tracy

    As I replied to your other post – http://wordpress.org/support/topic/48895#post-281470 – start your own topic and don’t repeat the same (or similar) question all over the forum.

    I want the ‘Pages’ menu list to list in the order of Home, etc, etc, and finish with Contact Us. At the moment it’s alphabetical, not great!
    Template_Tags/wp_list_pages see Sort by menu_order

    Could it be a problem naming the Categories the same as the Pages?
    Maybe not, it just doesn’t make sense.

    All pages from the main ‘Pages’ links are static eXtended pages (or will be if they’re not now), where there will be a bit of static text and then a summary of the latest 5 articles with ‘…more’ links to the full article.
    No, they will not be like that. Read Pages.
    What you want is Category_Templates

    And if you as new as you say: Getting_Started_with_WordPress

    Or, if you’re game for playing in MySQL (through phpMyAdmin or equivalent), you can switch the category ids and list them that way (which is default). Just make sure to back up your database before fooling around in there.

    Very, VERY bad idea as posts are assigned categories by category ID and changing the ID of a category won’t make the post change IDs, i.e. you’ll have posts in the wrong categories.

    i really (hmm … yes really) dont know, why the developers put that restriction on sort_column.

    see function list_cats(…) in wp-includes/template-functions-category.php (about row 296 in wordpress 2.0.4)

    $sort_column = ‘cat_’.$sort_column;

    maybe it’s for security reasons, but nevertheless i have no idea, how it could be exploited, if you could access every column in the mysql table via order.

    at first i thought to delete the mentioned statement in order to increase the power of the sort_column parameter in wp_list_cats or list_cats. But this means breaking the documented usage of the command (sort_column=name wouldn’t work anymore)
    this is why i added this simple condition before the statement:

    if($sort_column == “ID” || $sort_column == “name”)

    with this line before the mentioned statement it’s still possible to sort on name and ID, but now you can sort on
    “category_count” (posts in category),
    “category_nicename” (category slug) and
    “category_description” (obviously ..), too.

    so why that extra prefixing sort_column in list_cats()?

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Menu Order’ is closed to new replies.