Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJonathan Grieve
Treehouse Moderator 91,253 PointsFinal code seems to be different in WordPress 4.5
I'm working in WordPress 4.5 for all of these changes so the code that Zac uses to get this to work has changed.
Most of it is the same but there are a few changes from the code in the video, to the code in the project downloads and the code I used to get the dropdown settings to save. So for clarity. here is the code I used to get the dropdown menu setting to save in WordPress 4.5.
First, register the setting which is the same across all versions to date
<?php
register_setting( 'wpt_settings-group', 'wpt_select_test');
?>
Then add the theme setting below the code for the other fields. Again this code has not changed.
<?php
add_settings_field(
'wpt_slideshow_select',
'Dropdown field',
'wpt_slideshow_select_callback',
'wptsettings',
'wpt_slideshow_section'
);/**/
?>
Then in the callback function things start to change. Use the get options function as normal but as the paremamer use wpt_settings rather than wpt_select_test
<?php
function wpt_slideshow_select_callback() {
$options = get_option( 'wpt_settings' );
if( !isset( $options['wpt_select_test'] ) ) $options['wpt_select_test'] = 1;
?>
There may well be other ways of solving the issue of this code discrepancies but this is what worked for me :)