WordPress.org

Ready to get started?Download WordPress

Forums

Organize Categories by Slug (1 post)

  1. RoseRawr
    Member
    Posted 3 years ago #

    Hello!
    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:

    <?php
    /* collect categories */
    
      foreach($posts as $post) :
                $category = get_the_category('orderby=slug');
                $cats[$category[0]->cat_ID] = $category[0]->cat_name;
            endforeach;
    /* 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