WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Determine if is main blog (2 posts)

  1. xrun
    Member
    Posted 2 years ago #

    Hi.
    I need to determine if the current blog in a network subdomain installation is the main blog, and do one thing if it is, and another if it isn't.

    What I have so far is this:

    <?php $blogid = $wpdb->get_blog_prefix(BLOG_ID_CURRENT_SITE); ?>
    <?php if $blogid="1" { run some code } else {run some other code}; ?>
    <?php endif; ?>

    I know this won't work cause this isn't valid code, but just an outline of the idea of what I need. Is there a kind and helpful coder out there that would like to lend a hand with this? :)

  2. xrun
    Member
    Posted 2 years ago #

    Solved like this:

    <?php global $blog_id;
    if ($blog_id == 1) { /* Blog description for main blog */ ?>
    <a href="<?php bloginfo( 'url' ); ?>" title="<?php bloginfo( 'name' ); ?>"><?php bloginfo( 'description' ); ?></a>
    <?php } else { /* Blog name for other blogs */ ?>
    <a href="<?php bloginfo( 'url' ); ?>" title="<?php bloginfo( 'name' ); ?>"><?php bloginfo( 'name' ); ?></a>
    <?php } ; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic