[resolved] How can I call the BlogID? (3 posts)

  1. hauruapai
    Posted 6 years ago #


    I am adding in a page that will list all of my subdomains but I want to filter out the name of the subdomain that the page is called from ie:

    I have

    If a person on mydomain.com goes to view the list of other subdomains I don't want mydomain.com to come up in the list etc

    I have had a look at some plugins but the closest one that I can find to do want I want does not remove the current site from the list, so I will do my own. I have had a play with different terms but have not got the right one yet!

    thank you for your time :D

  2. David Sader
    Posted 6 years ago #

    $blog_id is a global. At least two (now deprecated in WP3 RC3) WPMU functions can produce a list of blogs, get_last_updated, or get_blog_list. Either function will generate an array of blogs with blog_id.

    FYI, some debate about leaving these (kinds of) functions in the final release of WP3:

    "That list could exceed the typical memcached object size limit."

    At any rate, however you query the db to get the list, check each against the $blog_id and unset it($n) from the array then loop/echo out the remaining blogs($details).

    global $blog_id;
    //$blogs = get_last_updated();
    $blogs = get_blog_list();
    if( is_array( $blogs ) ) {
    		foreach ( $blogs as $n => $blog ) {
    			if ( $blog['blog_id'] == $blog_id )
    				unset( $blogs[$n] );
    		}	?>
    	<?php foreach( $blogs as $details ) {
    		?><li><a href="http://<?php echo $details[ 'domain' ] . $details[ 'path' ] ?>"><?php echo get_blog_option( $details[ 'blog_id' ], 'blogname' ) ?></a></li><?php
  3. hauruapai
    Posted 6 years ago #

    thank you dsader - that code works beautifully.

    I also appreciate the link and can see why it may call problems... will have to think more about implementing this :D

    Once again, thank you for your help

Topic Closed

This topic has been closed to new replies.

About this Topic