WordPress.org

Ready to get started?Download WordPress

Forums

Sorting category dropdown list (1 post)

  1. taylorsuk
    Member
    Posted 2 years ago #

    Hello all,

    I am using User-Submitted-Posts Plugin in order to let users submit their images to my wordpress site. Each image is uploaded within a category. The categories are set in the wordpress admin area and are pulled into the submission form using the following code.

    My only problem is that this web form pulls the categories through ordered by their category ID not in alphabetical order. Therefore when i ADD a category even if it begins with the letter A, it will appear at the bottom.

    Can anyone let me know how to edit the following code to make all categories list in ASC alphabetical order?

    ` <li class="usp_category">
    <label for="user-submitted-category" class="usp_label"><?php _e('Categories'); ?></label>
    <div>
    <select class="usp_select" name="user-submitted-category" id="user-submitted-category">

    <?php foreach($settings['categories'] as $categoryId) { $category = get_category($categoryId); if(!$category) { continue; } ?>
    <option class="usp_option" value="<?php echo $categoryId;?> "><?php $category = get_category($categoryId); echo htmlentities($category->name); ?></option>
    <?php } ?>
    </select>
    </div>
    </li>`

Topic Closed

This topic has been closed to new replies.

About this Topic