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.
Method: 2
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
}
Uggh looks like the WP comment filter removed my code example. I’ve put it on pastie:
http://pastie.org/10673271
wow, I liked your approach.
updating this tutorial.
@Abdussamad Thanks for your input.
Thank you