4
votes

I'm integrating an external script with my wordpress theme and I'm getting this error in one of my files:

PHP Fatal error: Call to undefined function get_bloginfo()

this script is located in

themes/mytheme/myscript

And all files are included as following:

include(WP_CONTENT_DIR."/themes/mytheme/myscript/myfile.php");

how can I fix it?

5
Where (which file) are you including them? - naththedeveloper
@naththedeveloper I mean subfiles in my /script/ folder have relation and are included like that, each other. - middlelady
In your included files, is there a get_bloginfo() function definition ? - technico

5 Answers

6
votes

The issue is usually mysql related...you need to reset your wordpress db user password.
That is to say that the password for the database user for wordpress has expired and you don't know about it.
Either do a linux command-line

mysql -uroot -p
SET PASSWORD FOR <WPUSERNAME>@localhost = PASSWORD('whateveryouwant');

Or through phpmyadmin - users tab -> Edit privileges -> Change password

5
votes

you must include wp-blog-header.php in your main php like this

require WP_DIR.'/wp-blog-header.php';

being WP_DIR the main wp directory

2
votes

Please see this question: Wordpress php fatal error: Call to undefined function language_attributes()?

Make sure you have wp-config.php configured with the correct DB info.

1
votes

Open wp-config.php and go to your plesk/cpanel and make sure database name and user and password are the same. In my case, I had a wrong database password set! So I updated it to match the one in wp-config.php and that solved for me.

0
votes

I had a similar problem and none of the above worked. finally, I run wp-cli db repair and the problem was solved. for more information about installing and using wp-cli see their website