Home » Php » Update path for WordPress script-loader.php

Update path for WordPress script-loader.php

Posted by: admin February 25, 2020 Leave a comment


I’m working on a WordPress site that is showing some console errors. It is not finding the files for a few scripts that are being loaded from script-loader.php, which is a WordPress core file.
The issue is that the WordPress environment for this site contains all the WordPress core directories and files inside a directory called WP. Since WordPress is not considering that, it is not able to find the resources since the path is incorrect.
script-loader.php contains this line of code $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array( 'utils', 'jquery' ), false, 1 ); if I include /wp/ before wp-admin everything works as intended, but of course, I should not modify a core file.
How can I update the path without modifying a core file so WordPress will find these files?

How to&Answers:

Have you gone over the documentation for Having WordPress in a subdirectory? If you installed WordPress under the standard “root path” method, you may need to change your .htaccess file, note specifically the RewriteBase and second RewriteRule:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp/
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp/index.php [L]
# END WordPress

There are plenty of other resources on running WordPress from a subdirectory, but the basics generally boil down to:

  • Make sure your rewrite rules accommodate the directory you’re using
  • Make sure your siteurl and homeurl options are set properly