Skip to content

Instantly share code, notes, and snippets.

@atsea
Created August 6, 2014 15:16
Show Gist options
  • Save atsea/5af186392cfd021c9b1a to your computer and use it in GitHub Desktop.
Save atsea/5af186392cfd021c9b1a to your computer and use it in GitHub Desktop.
WordPress: Select list Class
class dropdown_category{
public static function getCategory(){
$template_swcategory = array(
' '=>"No Category",
'Antivirus and Security' => 'Antivirus and Security',
'Creativity' => 'Creativity',
'Database' => 'Database',
'Geographic Info Systems' => 'Geographic Info Systems',
'Graphing' => 'Graphing',
'Internet and Email' => 'Internet and Email',
'Mathematics' => 'Mathematics',
'Networking and FTP' => 'Networking and FTP',
'Office Productivity' => 'Office Productivity',
'Operating Systems and Utilities' => 'Operating Systems and Utilities',
'Statistical' => 'Statistical',
'Virtualization' => 'Virtualization'
);
return $template_swcategory;
}
}
/* Paste below in content area */
<select name="sw_category">
<?php
foreach ( dropdown_category::getCategory() as $key=>$value){
?>
<option value="<?php echo $key; ?>"
<?php
selected($sw_category, $key);
?>
><?php echo $value; ?></option>
<?php } ?>
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment