Problem js css and themes pointing to my local envinronment

Hi. I have problem I am deploying my wp to live site , when I launch the site my site is destroy due to my js and css is not loading properly it uses the url of my local , how can I change the path of my css and js to point to the live url ?

Thank you in advance.


If your live URL path has the same path as your local URL just omit the host from it. For example
Instead of http://localhost/path/to/my/asset.css have /path/to/my/asset.css.
If the paths were different then you could use a variable to set the base url depending on the host.

$baseUrl = 'http://localhost/mySite/';
if ($_SERVER['HTTP_HOST'] === '') {
  $baseUrl = '';
$styleSheet = $baseUrl.'styles/main.css';

Hope that helps.

I just edit the table wp_options if I remember then I change the Url to my live address

Use to move the site from local to live. It lets you replace the URLs in the database during the migration process.

Thanks for this :slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.