Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress WordPress Settings API Creating Multiple Setting Fields Dropdown Select Field Example

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 90,845 Points

Final 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

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.


        'Dropdown field',

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

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 :)