Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




get_id_from_blogname [ WordPress Function ]

get_id_from_blogname ( $name )
Parameters:
  • (string) $name
Returns:
  • (int) A blog id
Defined at:



Given a blog's (subdomain or directory) name, retrieve it's id.

Source


<?php
function get_id_from_blogname$name ) {
    global 
$wpdb$current_site;
    
$blog_id wp_cache_get'get_id_from_blogname_' $name'blog-details' );
    if ( 
$blog_id )
        return 
$blog_id;

    if ( 
is_subdomain_install() ) {
        
$domain $name '.' $current_site->domain;
        
$path $current_site->path;
    } else {
        
$domain $current_site->domain;
        
$path $current_site->path $name '/';
    }
    
$blog_id $wpdb->get_var$wpdb->prepare("SELECT blog_id FROM {$wpdb->blogs} WHERE domain = %s AND path = %s"$domain$path) );
    
wp_cache_set'get_id_from_blogname_' $name$blog_id'blog-details' );
    return 
$blog_id;
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics