localhost - How to make other computer in local network see my theme

admin2025-06-03  3

I have made WordPress Theme and have 2 themes in WordPress repository. So, I do not hard code my themes and pretty well how to use WordPress Theme goes to online.

I use WAMP server with 127.0.0.1 and my local IP is 192.168.100.103. Everything is ok in my computer.

Other computer, try to see my theme. And, only the HTML, the rest (js and css) is not loaded. I have checked with firebug. Then i see the path is http://localhost/wp-theme/css.. It should be http://192.168.100.103/wp-theme/css..

How to change the path? Or does any setting with WAMP?

I have made WordPress Theme and have 2 themes in WordPress repository. So, I do not hard code my themes and pretty well how to use WordPress Theme goes to online.

I use WAMP server with 127.0.0.1 and my local IP is 192.168.100.103. Everything is ok in my computer.

Other computer, try to see my theme. And, only the HTML, the rest (js and css) is not loaded. I have checked with firebug. Then i see the path is http://localhost/wp-theme/css.. It should be http://192.168.100.103/wp-theme/css..

How to change the path? Or does any setting with WAMP?

Share Improve this question asked Mar 5, 2015 at 5:56 ucon89ucon89 3261 gold badge3 silver badges7 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 8

Go to Admin Panel > Settings > General and replace localhost with your ip-address for WordPress Address (URL) and Site Address (URL) and see if it works. Also don't forget to put your WAMP server online.

If you are enqueueing your css with wp_enqueue_style, Wordpress will embed the site's url in the style call. Since you defined your site as "localhost", that's what you'll get (even if you access the site using the IP address instead of localhost).

If you are going to access your site from any other machine, defining the site's address as localhost (or 127.0.0.1) wont cut it. You need to use the ip address/domain of your machine, the same one you'll use in the second machine to access the one hosting the wp installation.

E.g.: machine hosting wp is on 192.168.100.103 On the Wamp machine you could add on your hosts file

site.local    127.0.0.1

And on the other machine's hosts file:

site.local 192.168.100.103

Then going to http://site.local in either of them will end up in the same machine.

Since your site is already configured, doing that wouldn't be enough. You need to change the URL in wordpress as well. E.g., in wp-home.php set:

define( 'WP_HOME', 'http://site.local' );

And if you have any content, menus, or anything like that, they'll be pointing to the old URLs. You need to reset them. You could do it by installing wp-cli and doing wp search-replace localhost site.local --recurse-objects; or you could just install this, and do the search replace in place as well.

Hope it all helps, and that you understand what's going on.

That didn't work for me. I found that I had to reinstall Wordpress using the IP address of the external PC as the Database Host. I could also use the WAN address from my ISP and view it from outside my local LAN.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748940021a315001.html

最新回复(0)