Ready to get started?Download WordPress


Organize Categories by Slug (1 post)

  1. RoseRawr
    Posted 3 years ago #

    I am having trouble organizing my categories by slug... any ideas?

    Here is the code I am using:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    I am thinking that this part is where the changes should be, but I am not sure:

    /* collect categories */
      foreach($posts as $post) :
                $category = get_the_category('orderby=slug');
                $cats[$category[0]->cat_ID] = $category[0]->cat_name;
    /* uncomment next line to have categories sort alphabetically */
    //    uasort($cats, strcasecmp);
        $cats = array_flip($cats);

    Thank you for your help!

Topic Closed

This topic has been closed to new replies.

About this Topic