WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm just doing some wordpress development and wondered for a brand new install, which code within core is generating the first value that get's filled into the home option?

I'm looking for the code in core, e.g. the filename and the line where this happens.

Does someone remembers from mind?

share|improve this question
up vote 6 down vote accepted

When the installer runs it calls wp_install(), that in turn calls populate_options() defined in wp-admin/includes/schema.php, which runs the following..

if ( !__get_option('home') ) update_option('home', $guessurl);

Prior to that $guessurl is defined by..

$guessurl = wp_guess_url();

The guess URL function is defined in wp-includes/functions.php and looks like this.

function wp_guess_url() {
    if ( defined('WP_SITEURL') && '' != WP_SITEURL ) {
        $url = WP_SITEURL;
    } else {
        $schema = is_ssl() ? 'https://' : 'http://';
        $url = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    return rtrim($url, '/');

Hope that's the info you're looking for... :)

share|improve this answer
wow dude, thanks a lot! – hakre Mar 18 '11 at 18:00
You're welcome.. :) – t31os Mar 18 '11 at 18:34
Related ticket is #16884. – hakre Mar 18 '11 at 20:38
@t3los -- There's not much room for improvement on your answer. Would you care to share any of the tools you used to look up this information? Maybe you did it manually, but I'm wondering if you have any tricks up your sleeve... Maybe it's worth it to figure out how to use phpdoc? Thanks in advance! – joelhaus Mar 19 '11 at 8:43
Just did it by hand, me, notepad++ and 5 minutes of spare time. Notepad++ can scan through all the WordPress PHP files for a string of text within a minute(it's usually faster/easier to do that than it is to search the web/codex/other-sources). Sorry if you were expecting something more elaborate ... :) – t31os Mar 19 '11 at 9:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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