Support » Plugins » Local Host \ Online Hack

  • Evidently the coders of WordPress, never assumed that I would like to host WordPress from a machine and use it on that very same machine. Now, I know there a serious reprecussions of dealing with the matter this way, but I decided that it would work well enough for my purposes.

    Place this code inside of your get_settings() function in the function.php file of WordPress.

    // Allow Local & Online Viewing
    if ( 'siteurl' == $setting || 'home' == $setting ) {
    $ip = $_SERVER['REMOTE_ADDR'];

    if ('' == $ip) {
    $value = 'http://localhost';
    } else {
    $value = 'online url';

    The best idea for your viewers would be to make your default siteurl in your options to the online URI, so that way they can get all the benefits, while you get basic access, just enough to play around though. I’ll eventually make a more extensive hack to give the same online abilities to local, and hell, if I can figure out how I can manage it, I might make it a a plugin.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Hi, Direkt,

    I have the same problem. So I want to install this feature. But where is “function.php” in WordPress ?? Also see my discussions under “side bar is main screen

    Yeah, nice to see another self-hoster around these parts. It’s located in your wp-includes function. But I expierenced that anything that requires you to pull the site url from the MySQL database generally outputs your set site url. I plan to make a better and manageable hack for it.

    I hope you will post it then or mail me at if it takes longtime

    Hopefully I can make a quick fix for this, but there are no guarentees.

    Alright, I’ve made a cleaner hack this time, and it removes most ( if not all ) of the reprecussions you’d get from doing my method mention above. I’ve made a nice .ZIP file for you Windows users, but I’d really also like if you’d host it on your own site if it proves rather useful.

    Mmmm, ever thought about changing the etc/hosts file on your machine, so that ‘online url’ links to ?

    As far as I got it, you’d only like your system to be available from your machine as well as from the internet. Adding that part to the hosts file, it is treated like a DNS entry and your machine connects to itself without using the internet connection.

    The hosts file is in Unix under /etc/hosts and in Windows under %WIN_DIR%/system32/drivers/etc/hosts …

    Hi, all, Well I will try all proposed items. Let you know…. Why is it always getting late….or better: early in front of the pc

    Ok, the hack from Direkt works OK, so, I’m happy. Let’s study further. Thanks Direkt. Bob58: I run WordPress on Win98SEII, so could not find your trick, so could not try it

    Best regards


    On Windows boxen the hosts file lives somewhere silly like:


    But bob58 really has the right idea, your machine should answer to the name of the host locally as well as from the internet.

    It takes a whole 5 mins to run WP on your computer via this: So yes, someone already thought people would like to run WP on their own computer

    Sounds like “LOCALHOST” is not resolving… this hack is kludge. Fix the problem underneath…

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Local Host \ Online Hack’ is closed to new replies.