WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Get Blog Path with WordPress 3.0 Multisite (4 posts)

  1. Equal Web Creative
    Member
    Posted 3 years ago #

    I have a multisite installation and I need to be able to get the path of the blog in my functions.php file in my theme. For example the main blog is here:

    http://multisite.domain.com/

    So the path I need returning would be '/'. If this was a blog:

    http://multisite.domain.com/blog/

    Then I would need to return '/blog/' I can see that the path is stored someone because clicking on edit site shows me it in the first option box.

    Any help with this would be appreciated.

    Thanks,

  2. dgilmour
    Member
    Posted 3 years ago #

    http://codex.wordpress.org/WPMU_Global_Variables

    Usage example from http://mu.wordpress.org/forums/topic/12800#post-76870:

    I'm using 2.7 and I find I can just do the following:

    global $current_blog;
    $blog_id = $current_blog->blog_id;

    And $blog_id contains the right value.

  3. This should work: http://codex.wordpress.org/Function_Reference/get_bloginfo

    Even if you use the same theme for all sites on your MultiSite, it should return the right data for the site you're 'in.'

  4. Equal Web Creative
    Member
    Posted 3 years ago #

    @djilmour

    Thanks for that - just the stuff I was looking for and it works a treat. Thats saved me a lot of hassle :)

    My solution in the end was this to output the path of the current blog/site:

    <?php global $current_blog; $blog_path = $current_blog->path; echo $blog_path; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic