• Resolved hauruapai

    (@hauruapai)


    Hi,

    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
    mydomain.com
    1.mydomain.com
    2.mydomain.com
    3.mydomain.com

    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 ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • $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:
    https://core.trac.www.ads-software.com/ticket/13773

    “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).

    <?php
    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] );
    		}	?>
    	<ul>
    	<strong>Blogs</strong>
    	<?php foreach( $blogs as $details ) {
    		?><li><a href="https://<?php echo $details[ 'domain' ] . $details[ 'path' ] ?>"><?php echo get_blog_option( $details[ 'blog_id' ], 'blogname' ) ?></a></li><?php
    	}
    	?>
    	</ul>
    	<?php
    }
    ?>
    Thread Starter hauruapai

    (@hauruapai)

    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 ??

    Once again, thank you for your help

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How can I call the BlogID?’ is closed to new replies.