The MU forums have moved to WordPress.org

blogname of MAINBLOG in wpmu?? (6 posts)

  1. sepp88
    Member
    Posted 14 years ago #

    i know this is a often found question, however i can't find a solution. i need a very simple thing. i have a header-element in a sidebar which links to my MAINBLOG via

    echo '<li>'. '<a href=' . get_option('index.php') . '/>' .'blogname of mainblog' .'' . '</li>';

    how can i get the blogname of the mainblog?

    regards sepp88

  2. kgraeme
    Member
    Posted 14 years ago #

    We're doing something similar but getting the Site Name (overall wpmu install name) rather than the root blog name (blog id 1). So for us it would look something like:

    echo '<li><a href="' . $current_site->path . '">' . $current_site->site_name .'</a></li>';

    Dunno if site_name works for you though.

  3. andrea_r
    Moderator
    Posted 14 years ago #

    Or if you're in there editing anyway and not re-releasing the theme, just hardcode the actual URL. One (or two) less database calls.

  4. sepp88
    Member
    Posted 14 years ago #

    first of all $current_site gets the CURRENT SITE, doesn't it. i don't want to get the current site, but want to get the name of the mainblog.

    so i'm using this code in my sidebar, if i use current_site i always get the name of the blog i'm on. however i just want the name of the blog with the ID of 1 (my mainblog)...

    and i don't want to hardcode it, because i think of releasing the theme sooner or later.

  5. LoganSix
    Member
    Posted 14 years ago #

    Apparently you there isn't a function for it. However, since the Main Blog will always be 1, you can use the get blog by id to get the url and name.

    For example.

    <a href="<?php _e(get_blogaddress_by_id('1')); ?>" title="<?php _e(get_blog_option(1,'blogname')); ?> Home" rel="home"><?php _e(get_blog_option(1,'blogname')); ?> Home</a>

  6. sepp88
    Member
    Posted 14 years ago #

    thank you, that's exactly i was searching for!

About this Topic