Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7163655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:56:21+00:00 2026-05-28T13:56:21+00:00

I am using User-Submitted-Posts Plugin in order to let users submit their images to

  • 0

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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:56:22+00:00Added an answer on May 28, 2026 at 1:56 pm

    I can’t actually try this, and i have no ideea how your plugin works… but the easiest solution that comes to my mind is to do 2 foreach loops. This would be inside your <select></select> :

        <?php
        $cats = array();
        // get what you need in an array
        foreach($settings['categories'] as $catid) {
            $cat = get_category($catid);
            if(is_object($cat)) $cats[$catid] = $cat->name; // why htmlentities() ?
        }
        // sort by name
        asort($cats);
        foreach($cats as $catid => $catname)
            echo "<option class=\"usp_option\" value=\"{$catid}\">{$catname}</option>";
        ?>
    

    hope it works/helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using PHP's DOMDocument to parse and normalize user-submitted HTML using the loadHTML method
I am trying to clean up user submitted comments in PHP using regex but
I've been using user controls extensively but never use a HttpHandler and was wondering
I am trying to create a trapezoid using user inputted options. I know my
Are use cases just multiple user stories?? What are the benefits of using user
I want to notify an user using Chrome browser. I need something powerful like
I'm attempting to authenticate a user against ADAM using a user I created in
Is it alright to expect that the user using the back end will have
I get the memberOf property for my user using this code: DirectorySearcher search =
How to determine the browser of the user using PHP? So that if the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.