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 a Theme Options Page Settings Coding a Simple Theme Options Page

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 90,705 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.