Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue with Wordpress After Moving Files

So I moved my installation of WP to a different folder in my web directory (to the root from a sub directory /wp) and now I have a fatal error, and cannot seem to fix it. Here are the errors:

Warning: array_keys() expects parameter 1 to be array, string given in D:\Hosting\2974365\html\wp-includes\class-wp-roles.php on line 126


Warning: Invalid argument supplied for foreach() in D:\Hosting\2974365\html\wp-includes\class-wp-roles.php on line 126

Fatal error: Cannot unset string offsets in D:\Hosting\2974365\html\wp-includes\widgets.php on line 1141

Any help would be greatly appreciated... can't figure it out for the life of me.

like image 661
Hasteify Avatar asked May 14 '26 04:05

Hasteify


1 Answers

Anytime you move Wordpress, you need to change the siteurl and the home to the new path. Apart from that, if you have posts, you also need to update their URL. Here is some SQL to help you do it, make sure you change the OLD_URL and NEW_URL fields.

Login phpMyAdmin, select the database and after you change the fields, execute the following queries:

UPDATE wp_options SET option_value = replace(option_value, 'OLD_URL', 'NEW_URL') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'OLD_URL','NEW_URL');

UPDATE wp_posts SET post_content = replace(post_content, 'OLD_URL', 'NEW_URL');

UPDATE wp_postmeta SET meta_value = replace(meta_value, 'OLD_URL', 'NEW_URL');

like image 52
I.T. Avatar answered May 16 '26 18:05

I.T.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!