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 trial

WordPress WordPress Settings API Creating a Theme Options Page Settings Coding a Simple Theme Options Page

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,252 Points

Using add_theme_page()

Hi all,

Just quickly clear up a couple of things. I have this snippet here in the WP settings course,

<?php
function wpt_add_theme_page {

add_theme_page( 
        __('Theme Options', 'wpsettings'), 
        __('Theme Options', 'wpsettings'),
        'edit_theme_options',
        'wptsettings',
        'wpt_theme_options_page'
    );

}
add_action('admin_menu', 'wpt_add_theme_page');
?>

I'm assuming a couple of things here. One that wpsettings refers to the folder of the theme that the theme files are contained in for the active WordPress theme and that instead of wpsettings, Zac means wptsettings because this is actually what the folder says in the project downloads.

So the code instead should read,

<?php
function wpt_add_theme_page {

wpt_add_theme_page( 
        __('Theme Options', 'wptsettings'), 
        __('Theme Options', 'wptsettings'),
        'edit_theme_options',
        'wptsettings',
        'wpt_theme_options_page'
    );

}

add_action('admin_menu', 'wpt_add_theme_page');
?>
pk15
pk15
1,692 Points

Yes you are right, "wpsettings" should be changed to "wptsettings". Thank you for the heads up.