Skip to:
Content
Pages
Categories
Search
Top
Bottom

Detect if this is the main blog


  • Sgrunt
    Participant

    @sgrunt

    Hi all, this is not a strictly bp question but a MU one, but i think it should be very useful for buddypressers.

    I need to write a condition:

    if (this blog is the main blog) do this

    else

    (do another thing)

    it is possibile to detect if a blog is the main blog?

    tnx!

Viewing 8 replies - 1 through 8 (of 8 total)

  • talk2manoj
    Participant

    @talk2manoj

    You might make use of following code

    //Main blog has always id as 1, so you can write

    get_header();

    if($wpdb->blogid == 1) {
    //do something
    } else{
    //do this
    }


    Sgrunt
    Participant

    @sgrunt

    really thanx!


    Sgrunt
    Participant

    @sgrunt

    if possible i’d like to ask another question:

    i want to show in the main blog the recent post from ALL blog, and in the sub blogs only the post from that SINGLE blog.

    the if condition is ok, and the main blog call all blogs recent posts:

    $posts = bp_blogs_get_latest_posts( null,10 ) ?>

    it is working fine for the main blog, now i must think to sub blogs. How can i edit it for showing only the current blog recent posts changing only a line?


    talk2manoj
    Participant

    @talk2manoj

    You can make use of widgets available in BuddyPress and WordPress.


    Sgrunt
    Participant

    @sgrunt

    yes i know, but i’m working on a particular blog: users need to have all the same ready made interface, thay are not allowed to activate or deactivate widgets in that area. This will be a free theme/application that i’ll share as usual with the community


    Sgrunt
    Participant

    @sgrunt

    no problem, i’m gonna see the light :-)

    updated: ok solved!


    talk2manoj
    Participant

    @talk2manoj

    In that case you can take the code or functions from widget and use them in your theme.


    nicolagreco
    Participant

    @nicolagreco

    there is a conditional function:

    is_main_blog()

    – Nicola

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Detect if this is the main blog’ is closed to new replies.
Skip to toolbar