The MU forums have moved to WordPress.org

Query for blog path. (5 posts)

  1. honewatson
    Member
    Posted 14 years ago #

    Hi I've been trying to write a query that finds the current blog path and assigns it to a variable for a subdirectory install.

    Any help with this would be much appreciated.

  2. lunabyte
    Member
    Posted 14 years ago #

    Current blog path... like how, and from where exactly?

    While on a specific page, or something like that?

    Need more info, although you could look into the output of the current_site global variable.

  3. honewatson
    Member
    Posted 14 years ago #

    Thank you for your reply Lunabyte. I was using this query in a template.

    I managed to figure it out although there may be a better way:

    <?php
            global $wpdb;
            $currenblogid = $wpdb->blogid;
            $blogpath = $wpdb->get_var( "SELECT path FROM $wpdb->blogs WHERE blog_id = '.$currentblogid.'" );
    ?>

    I was using this for the folder installation version of mu wordpress. This basically gets the folder name.

    So for a site like so:

    http://musite.com/blog1/

    $blogpath will return /blog1/

  4. lunabyte
    Member
    Posted 14 years ago #

    There is a better way. Like I said, check out the current_site global.

    Lots of data already available for ya, without more queries.

  5. honewatson
    Member
    Posted 14 years ago #

    Thanks I'll check it out.

About this Topic

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