WordPress.org

Forums

WordPress: difference between site_id and blog_id? (11 posts)

  1. gromag
    Member
    Posted 4 years ago #

    This morning I've posted this question to stackoverflow forum but it seems it got unnoticed. Probably I should have posted it here in the first place.

    Hi

    I'm trying to get some understanding of how WordPress works and while inspecting the database I found that, in a multisite installation, there is a table called wp_site that seems always holding a single record with a corresponding site_id. I cannot understand (nor find on internet) what is the use of site_id when actually multisites seem to use wp_blogs and corresponding blog_id for identifying different sites.(http://codex.wordpress.org/Database_Description)

    Can someone shed some light on what should be my understanding of site_id?

    Thanks

    Giuseppe

  2. govpatel
    Member
    Posted 4 years ago #

    As you noticed that wordpress does not call it blog any more they call it sites as multi sites or My Sites in old wordpress use to be blog

  3. gromag
    Member
    Posted 4 years ago #

    Hi Govpatel,

    thank you for replying. Can you articulate your answer further, please bear in mind I have very recently started using WordPress.

    Many thanks

    Giuseppe

  4. govpatel
    Member
    Posted 4 years ago #

    Blog name has been replaced with Site in wordpress 3.0

  5. Patrick Daly
    Member
    Posted 4 years ago #

    As far as code and database goes, "blog" is still used.

    The site_id is the domain associated with your WP installation. Through the use of plugins (i.e. Domain Mapping), its possible to have multiple site_ids.

  6. alaahd
    Member
    Posted 4 years ago #

    RT: @Patrick Daly, perfect answer

  7. Zambrano Sergio
    Member
    Posted 3 years ago #

    Patrick:

    Through the use of plugins (i.e. Domain Mapping), its possible to have multiple site_ids.

    Does that mean that the site_id is only related to the domain but not the blog?

    Will changing the site_id change the domain a blog is linked to?
    … or changing it would result in the info taken from the new id blog?

    Can blog_id and site_id be different?

    Can use site_id without or instead of blog_id? ( site_id seems to be "optional" ) I assume changing blog_id is enough to switch what sub-blog the functions should work on.

    I'm trying to get content from the main blog, and I found the info to do it, but I was wondering whether it's possible to rather change the url (domain) of that content showing the blog they were called from, and keep the rest of templates unchanged, because it'd be easier than changing blog_id every time a content is read.

  8. Eyecool
    Member
    Posted 3 years ago #

    It's so simple, make it a rule of thumb and you'll never forget. (remember you only have two thumbs!)

    site_id = the network
    blog_id = the sites (formerly known as blogs)

    That's it!

    site_id=1 and blog_id=1 <-- that's your main domain. The one you installed WordPress on. By enabling multisite, it becomes the network and the site. This only happens once.

    site_id=1 and blog_id=2 <-- that's your second site.
    site_id=1 and blog_id=3 <-- that's your third site.

    Take a peek at your wp_blogs table. It's a cool place! :)

  9. tomaltman
    Member
    Posted 3 years ago #

    This all true - but if you look at how the database is built, it really appears they have built it to allow for many layers in the future.

    Like - if you look into wp_posts you can have site and blog id's...I think this is is useful for WP Multisite - but almost a little bit of future-proofing.

  10. Eyecool
    Member
    Posted 3 years ago #

    Sure! There's a lot you can do. For example, automattic uses site_id=1 for all wordpress.com blogs and site_id=2 for self-hosted .org sites that use jetpack or stats.

  11. Zambrano Sergio
    Member
    Posted 3 years ago #

    Clear enough. Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic