Tell us what you are trying to do?
Add "United States" twice in a country drop-down select (once at the top and once alphabetically)
Is there any documentation that you are following?
I don't know
Is there a similar example that we can see?
hidden link (top list)
What is the link to your site?
hidden link
Hi Jason,
Following up on our earlier discussion, you can also use "wpt_field_options" filter, to find the select option for "United States" and add its duplicate on top:
add_filter( 'wpt_field_options', 'func_to_duplicate_us_option', 10, 3);
function func_to_duplicate_us_option( $options, $title, $type ){
if ($title == "test") {
$find = "us";
$options_temp_default = $options[0];
for ($i=1; $i < count($options) ; $i++) {
$options_new[] = $options[$i];
if( $options[$i]['#value'] == $find) {
$options_temp_req = $options[$i];
}
}
array_unshift($options_new, $options_temp_req);
array_unshift($options_new, $options_temp_default);
$options = $options_new;
}
return $options;
}
The above code can be added in active theme's "functions.php" file and you'll replace "test" with the actual "Field name" set for the relevant custom field, in the settings.
( example screenshot: hidden link )
note: To make this function work for more than one select fields, you can update the line:
To:
if ( ($title == "test") || ($title == "test1") ) {
regards,
Waqar