I have a function(this is exactly how it appears, from the top of my file):
This errors says your function is already defined ; which can mean :
I think your facing problem at 3rd position the script including this file more than one time.So, you can solve it by using require_once instead of require or include_once
instead of include
for including your functions.php
file -- so it cannot be included more than once.
If your having a Wordpress theme problem it could be because although you have renamed the theme in your wp_options table you havn't renamed the stylesheet. I struggled with this.
In my case it was because of function inside another function! once I moved out the function, error was gone , and everything worked as expected.
This answer explains why you shouldn't use function inside function.
This might help somebody.
Don't declare function inside a loop (like foreach
, for
, while
...) ! Declare before them.
You should include that file (wherein that function exists) only once. So,
instead of : include ("functions.php");
use: include_once("functions.php");
If none of above helps, before function declaration, add a check to avoid re-declaration:
if (!function_exists('your_function_name')) {
function your_function_name() {
........
}
}
I had the same problem. And finally it was a double include. One include in a file named X. And another include in a file named Y. Knowing that in file Y I had include ('X')