wordpress tips and tricks, wordpress tips

Select Dropdown Countries Template for WordPress developers

Hello WordPressers,

I was working on a project where I had to add the countries dropdown on the signup page. So, for making select dropdown countries selection sticky in the case of error at signup, I needed to check the $_POST[‘countries’] with every option in the select dropdown. It seems a redundant effort to me as It took me 30 mins to do this task.




So, I am sharing this code with you people to free you from this 30 mins hassle.  In return all I need is a ‘Thank you’ !!!

 

Select Dropdown Countries Template for WordPress developers

 

Method: 1

This method is posted in our comments section.

http://pastie.org/10673271

Method: 2

4 thoughts on “Select Dropdown Countries Template for WordPress developers”

  1. Ooh this is a mess! Use an associative array and a foreach loop and you’ll be done in a few lines *and* the code will actually be maintainable.

    Example:


    'Pakistan', 'IN' => 'India' ) ; //so on
    ?>

    $name ) { ?>
    <option value="" >
    <?php
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.