简体   繁体   中英

Selectbox in wordpress theme options

I am currently creating some theme options in wordpress & I am trying to create a select box so the user can select a skin to use for the theme. I am new to wordpress theme options so I don't know a lot about them.

I am in need of some help with the php so that when the user selects one of the options it updates that option with selected="selected" & saves it and then the value of that option is sent to the header.php file so i can use it from there.

<select>
    <option value="" selected="selected">Select a skin</option>
    <option value="light.css">Light Skin</option>
    <option value="dark.css">Dark Skin</option>
 </select>

Thanks for any help!

Could not create a query to add the selected="selected"

for example:

<select>
    <option value="">Select a skin</option>
    <option value="light.css" <?php if($theme == $themename):?>selected="selected" <?php endif; ?>>Light Skin</option>
    <option value="dark.css">Dark Skin</option>
 </select>

You would add this to all <option> elements

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM