Newbie in wordpress coding. please tell how to create theme option pages.

function my_plugin_menu() {

    add_theme_page('Theme Options', 'Theme Options', 'edit_theme_options', 'theme-option-slug' , 'settings_page'); 

function settings_page()
    echo "aa";  

You created the callback function and the function for adding the Theme page, but you also have to tell WordPress when to call your function my_plugin_menu. You can do this by hooking into admin_menu.

add_action('admin_menu', 'my_plugin_menu');

This way WordPress knows that when it reaches the Scripts for admin_menu, it also has to execute your code, thus adding your Theme Page.

More information on this is available on the Codex.

  • sorry i forgot to mention add_action('admin_menu', 'my_plugin_menu'); but still no result – Alizain Prasla Feb 26 '13 at 11:23
  • Did you check the capabilities for the user where you are testing this? – fischi Feb 26 '13 at 11:25
  • i am super admin – Alizain Prasla Feb 26 '13 at 11:29
  • The Code you wrote above works perfectly fine. You may be Super Admin, but you can still lack the capability of edit_theme_options, those are two different things. Ehat happens when you load the page yourdomain.com/wp-admin/themes.php?page=theme-option-slug ? – fischi Feb 26 '13 at 11:34
  • Nice. So it was maybe just a caching problem :) – fischi Feb 26 '13 at 12:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.