The MU forums have moved to WordPress.org

blog id from post id? (8 posts)

  1. fleshins
    Member
    Posted 14 years ago #

    Is there a way to determine the blog id from the post id?

  2. Hassan1
    Member
    Posted 14 years ago #

    It's not possible because every blog has a post table and every table has a post ID column starts from one. In other words post IDs are not unique.

    If you explain more about your need We may find a better way.

  3. fleshins
    Member
    Posted 14 years ago #

    Thanks Hassan. I'm trying to get the $blog_name from a $post_id. Any ideas how to do that? Is this just possible w/ the current wpmu schema?

  4. fleshins
    Member
    Posted 14 years ago #

    So it looks like for the time being, all I really need is the current site's blog name being posted to. A call to get_option('blogname') returns the blog name.

    I'm a bit concerned about the long term implications of post IDs not being unique <sigh>. Moving on ..

  5. SteveAtty
    Member
    Posted 14 years ago #

    Post IDS are not unique because each blog keeps its posts in its own posts table, same as comments.

    It does make things harder in some ways and sometimes I cringe when I look at the WPMU DB schema.

  6. fleshins
    Member
    Posted 14 years ago #

    Thanks Steve - appreciate the post.

  7. SteveAtty
    Member
    Posted 14 years ago #

    But dont forget that if you've got a post_id then you have to have a blog_id - otherwise WPMU can't get the post or anything associated with it. So if you're in a block of code that has been called then the blog_id is there.

    If that makes sense?

  8. fleshins
    Member
    Posted 14 years ago #

    Nice. Makes sense.

    When I call get_permalink($post->ID), I'm returned the right permalink. Which must mean that get_permalink() is aware of the (current?) blog_id, otherwise it wouldn't be able to return a valid permalink.

    Thanks for the schooling :)

About this Topic

  • Started 14 years ago by fleshins
  • Latest reply from fleshins