1

I've uploaded a wordpress site but it's missing javascript and css. The links on the head still have the local path (src='https://localhost...') and not the new ones. So I guess it has to do with get_template_direcory_uri() that I use in fucntions.php to apply my javascript/jquery,bootstrap,css etc.

How yo fix that?

I've tried adding to config.php:

define( 'WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] );
define( 'WP_HOME',    'http://' . $_SERVER['HTTP_HOST'] );

and

define( 'WP_HOME', 'https://...' );
define( 'WP_SITEURL', 'https://...' );

but they didn't help...

4
  • Can you show how you enqueue your styles and scripts? Please make sure to use formatting, you can see how to do it from my edit
    – kero
    Commented Oct 28, 2019 at 12:59
  • Have you updated the all of your site links after the migration? Please show us your enqueue code Commented Oct 28, 2019 at 13:11
  • Have you set the correct URL in Settings > General? Commented Oct 29, 2019 at 5:40
  • I have the same problem. In a development environment I want to use settings different from those in wp_options table. In the back end I do see the grayed out versions of site_url and home conforming the setting in wp_config.php. However, get_template_directory_uri() just returns the one in wp_settings, not the one in wp_config.php.
    – th00ht
    Commented Apr 14, 2020 at 9:32

1 Answer 1

1

Do your URL change up in phpMyAdmin with SQL language:

# Change website url
UPDATE wp_options
SET option_value = replace(option_value, 'http://www.old-site.com','http://www.new-site.com') WHERE option_name = 'home' OR option_name = 'siteurl';

# Change GUID URL
UPDATE wp_posts SET guid = REPLACE (guid, 'http://www.old-site.com','http://www.new-site.com');

# Change url of medias, post, page, etc.
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://www.old-site.com','http://www.new-site.com');

# Change meta data url
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://www.old-site.com','http://www.new-site.com');
2
  • Thanks for your help. Commented Oct 29, 2019 at 8:08
  • Beware that this can break your site even further. WordPress stores some data serialized (especially in the postmeta and options table). Running these queries will destroy the serialized strings. Instead, you can use the WP-CLI (especially with the --precise flag) or plugins such as Better Search Replace.
    – kero
    Commented Oct 29, 2019 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.