WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Menu Order (12 posts)

  1. Anonymous
    Unregistered
    Posted 9 years ago #

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

  2. Mark (podz)
    Support Maven
    Posted 9 years ago #

    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.

  3. Kafkaesqui

    Posted 9 years ago #

    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.

  4. Anonymous
    Unregistered
    Posted 9 years ago #

    thanks

  5. Anonymous
    Unregistered
    Posted 9 years ago #

    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';

  6. Kafkaesqui

    Posted 9 years ago #

    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

  7. Beel
    Member
    Posted 9 years ago #

    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".

  8. Kafkaesqui

    Posted 9 years ago #

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

  9. Freelancealot
    Member
    Posted 8 years ago #

    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

  10. moshu
    Member
    Posted 8 years ago #

    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

  11. 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.

  12. japanitrat
    Member
    Posted 7 years ago #

    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()?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.