Hello I tried to find the solution but couldn't get what I am looking for..I am getting error exactly as bellow..

Notice: Undefined index: page in C:\xampp\htdocs\site\wp-content\themes\mytheme\admin\admin-panel.php on line 745

and code on line 745 is

function mytheme_add_init() {

wp_enqueue_style("functions", $file_dir."/admin/functions.css", false, "1.0", "all");
wp_enqueue_script("rm_script", $file_dir."/admin/rm_script.js", false, "1.0");


I dont know if I am using deprecated snippet or so.

  • 2
    Please provide us the entire source of your admin-panel.php file, or at least more code surrounding this line. There isn't anything in the code snippet you posted that's even using an index ... – EAMann Nov 18 '11 at 16:56
  • here is my admin-panel.php snipt.org/kgnlg6 Its too long and will goon for more options.. I would appreciate your help.. Thanks a lot Also kindly know me the mistake to learn.. – pixelngrain Nov 18 '11 at 18:56

Looking at your actual source, the relevant portion (with line numbers) is this:

745 if ( $_GET['page'] == basename(__FILE__) ) {
747     if ( 'save' == $_REQUEST['action'] ) {
749         foreach ($options as $value) {
750             update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
752         foreach ($options as $value) {
753             if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ]  ); } else { delete_option( $value['id'] ); } }
755     header("Location: admin.php?page=admin-panel.php&saved=true");
756     die;
758 } 

You're checking for "page" inside the global $_GET variable, but in this case, it's not set. You need to run an isset() check first.

745 if ( isset( $_GET['page'] ) && $_GET['page'] == basename(__FILE__) ) {

This will first check to see if we've passed in a value for 'page' in the request. If not, then we move on. If we have passed one in, though, then we'll compare it to basename(__FILE__) as normal.

You should use this same isset() pattern with $_POST and $_REQUEST variables as well, otherwise you'll get the same notices.

  • I have modified code as per your direction and error gone for my admin panel but for front end error still remains the same Here is my modified admin-panel.php snipt.org/kww9 Front end error message is " Notice: Undefined index: id in C:\xampp\htdocs\pixelngrain\wp-content\themes\Pixel_n_Grain\header.php on line 10" and its not only for header but for all where I am using this code plus variable to get theme options.. also adding header.php to see if I am wrong anywhere. snipt.org/kwG0 for your information I am not familiar much with php and still learning yet. – pixelngrain Nov 19 '11 at 4:12
  • Look at line 10 in header.php. You're calling get_settings( $value['id'] ) but aren't first checking that "id" is set in the $value array. It's the exact same problem you had before. You need to check to see if "id" is set first. Change your if statement from if (get_settings( $value['id'] ) === FALSE) to if ( isset( $value['id']) && get_settings( $value['id'] ) === FALSE) – EAMann Nov 20 '11 at 16:54
  • Thanks for reply EAMann, I have tried and modified below code but still same error exists <?php global $options; foreach ($options as $value) { if ( isset( $value['id']) && get_settings( $value['id'] ) === FALSE) { $value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); } } ?> – pixelngrain Nov 20 '11 at 18:00
  • The exact same error? Or just an "undefined index" warning? If you changed the code in such a way, then that particular "undefined index" warning for header.php would disappear. – EAMann Nov 20 '11 at 23:45
  • 1
    The undefined index: std is because you're calling $value['std'] without first checking if it's set. Ultimately, you need a check before you run any of this code to make sure that $value is the type of array/object that you expect. These warnings are meant to tell you that you're trying to access values and properties that don't exist. Don't just assume that they're there, check first then run the rest of your application logic. – EAMann Nov 21 '11 at 17:04

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.