WordPress add options to theme not displaying

Hi I am trying to learn to add theme options to WordPress themes by reading The Complete guide to WordPress Settings Api on wptuts I have gotten as far as the 4th part and have stoped to create an example for myself because I have gotten confused with how can I add the sections I create in a page.Here is my code:

 function thanatos_theme_menu(){
    add_theme_page(
                   "Thanathos Theme Options", 
                   "Thanathos Theme", 
                   "administrator", 
                   "thanathos_theme_options",
                   "thanathos_theme_display_callback"
                  );
}
add_action('admin_menu' , 'thanatos_theme_menu');
function thanathos_theme_display_callback(){
      echo "Johny la hanta este mui loca"; 
}

add_action('admin_init' , 'thanatos_initializa_theme_options');
function thanatos_initializa_theme_options(){
    add_settings_section(
            'general_settings_section', 
            'Thanatos Options', 
            'thanatos_general_options_callback', 
            'thanathos_theme_options' //I believe this where my mistakes is 
    );
}

function thanatos_general_options_callback(){
    echo 'mergem la mare';
}

I have used the page id in order to set where to put this section and I belive the thanatos_general_options_callback() should display there but for some reasons it doesn’t.What am I doing wrong here?

Related posts

Leave a Reply

2 comments

  1. I think you may need to use the functions settings_fields do_settings_sections and register_setting as well as add_setting_section to get this working see refs. to these functions here. I’m not sure if you could get a bare bones version working leaving some of those out but maybe or maybe not … there are a lot of functions used in a working options page I know.

    I would advise copying a finshed working options page such as Jeffrey way’s offering into your theme and removing stuff till you get to a bare bones working model. It will help you to understand this as it’s pretty complex.

    It’s also complex enough to warrant setting up multiple practice themes on your system so you can experiment with different versions/stages of an options page if it’s your first venture into it.

    Also in research be aware of the “Old way” and “New way” of doing settings. Settings API is the “New way”

    Edit – as Eric Said, having “administrator” as capability is suspect.

  2. You have one main in your add_theme_page() call.

    Please use the codex as reference.

    Where you have “administrator” you are giving the function a role, as opposed to a capability. Use “install_themes” instead.

    The probable situation is that when you are logged in you do not have the ‘administrator’ capability (as it does not exist) so the page is not displaying for you.