black vertical signboard mockup

As a wordpress theme developer, when you are working with WP_DEBUG on, you are most likely to get the following notice: “Notice: Undefined index….some_variable“.

This warning is caused by the fact that the variable is empty or unset when the wordpress theme is activated or at some other point.

You can solve this warning pretty quick with just few lines of code. Let’s assume the variable we are getting the error for it’s called $some_variable. Here it’s how you do it.

[php]

<?php

if  (!empty($some_variable)){

//your output of the variable e.g. echo $some_variable;

}

?>

[/php]

 

Published by Graphic Xtreme