how to customize my wordpress post form by adding drop down list?
I m still a novice for WP. i need to customize my admin post form by adding drop down list. List options should be come from one of my WP database table's column....i found lots of plugin for adding new input fi开发者_高级运维eld to my post form. but it is not supported to getting list option values from WP database to the drop down list. i m much thankful if someone can help me.
You can make use of the global $wpdb object. The $wpdb object allows you to run queries on any table in the Wordpress database. For example:
$query = "SELECT * FROM options WHERE parameter='value' ORDER by columnichoose DESC"
$query = $wpdb->prepare($query);
$results = $wpbd->get_results($query,ARRAY_A); // ARRAY_A tells it to return an associative array, objects and numeric arrays can also be selected.
foreach ($results as $result)
{
$html .= "<option value='" . $result['columnneeded'] . "'>".$result['columnneeded'] . "</option>";
}
If you're talking about adding a custom meta box with values from MySQL, that's certainly possible.
Have a look at this page from the wordpress codex, and mix in the answer given by Liam to generate the values for the meta box.
精彩评论