Hey zusammen,
bin dabei eine eigene Options Page zu programmieren.
Allerdings komme ich gerade nicht weiter ein Select Field abzuspeichern.
Mein Code sieht wie folgt aus.
PHP
//Activate custom settings
add_action( 'admin_init', 'webkfz_custom_settings' );
function webkfz_custom_settings() {
register_setting( 'webkfz-settings-group', 'customer' );
register_setting( 'webkfz-settings-group', 'countcars' );
register_setting( 'webkfz-settings-group', 'stilList' );
add_settings_section( 'webkfz-all-options', '', 'webkfz_options', 'webkfz');
add_settings_field( 'customer', 'Kunde', 'webkfz_customer', 'webkfz', 'webkfz-all-options');
add_settings_field( 'countCars', 'Anzahl der Fahrzeuge in der Liste', 'webkfz_countcars', 'webkfz', 'webkfz-all-options');
add_settings_field( 'stilList', 'Stil Listenansicht', 'webkfz_stilList', 'webkfz', 'webkfz-all-options');
}
function webkfz_options() {
}
function webkfz_customer() {
$firstName = esc_attr( get_option( 'customer' ) );
echo '<input type="text" name="customer" value="'.$firstName.'" placeholder="First Name" />';
}
function webkfz_countcars() {
$countCars = esc_attr( get_option( 'countcars' ) );
echo '<input type="text" name="countcars" value="'.$countCars.'" placeholder="Anzahl der Fahrzeuge" />';
}
function webkfz_stilList() {
$stilList = esc_attr( get_option( 'stilList' ) );
echo '<select>
<option value="volvo">Card Default</option>
<option value="saab">Card Primary</option>
<option value="mercedes">Card Secondary</option>
<option value="audi">Card Hover</option>
</select>';
}
function webkfz_theme_create_page() {
require_once( '/templates/webkfz-admin.php' );
}
Alles anzeigen
Mit den Textfield hat alles wudnerbar geklappt. Könntet Ihr mir evtl. eine Anregung geben wie ich das Select Feld auch abspeichere?