1

How i can get blog info using site url in multi-site

for eg : if i give the site url as http://a.somename.com and this should return me the value like

Site Name

Site Tag line

Site Database Table Prefix

Used Code

$blog_id = get_blog_id_from_url("http://192.168.0.89/dev/sareepuram/ss/");
echo get_blog_option( $blog_id, 'blogname' );
echo get_blog_option( $blog_id, 'blogdescription' );

If i use the above code i get the details for the below link

http://192.168.0.89/dev/sareepuram/

I use wordpress multi-site

The below link is the main site

http://192.168.0.89/dev/sareepuram/

And this link is the sub site http://192.168.0.89/dev/sareepuram/ss/

My Code Page Looks Like Below

<?php
define('WP_USE_THEMES', false);
require('wp-load.php');

$blog_id = get_blog_id_from_url("http://192.168.0.89/dev/sareepuram/ss/");
echo get_blog_option( $blog_id, 'blogname' );
echo get_blog_option( $blog_id, 'blogdescription' );

?>
4
  • If you are using sub directory install then you should use $blog_id = get_blog_id_from_url("http://192.168.0.89/dev/sareepuram","/ss/"); Apr 12, 2013 at 6:49
  • @VinodDalvi Not Working Sir Apr 12, 2013 at 6:51
  • Try echo get_blog_option( $blog_id, 'siteurl' ); Apr 12, 2013 at 6:55
  • i tried but i get the main site details only Apr 12, 2013 at 7:01

1 Answer 1

2

Use get_blog_id_from_url() function to retrieve blog id from url and then use get_blog_option() function to get information for that blog.

Example :

$blog_id = get_blog_id_from_url("a.somename.com");
echo get_blog_option( $blog_id, 'siteurl' );
echo get_blog_option( $blog_id, 'blogname' );
echo get_blog_option( $blog_id, 'blogdescription' );
6
  • Not Working For Me Apr 12, 2013 at 6:31
  • What is it displaying? are you getting any error? Apr 12, 2013 at 6:32
  • i have already tried using get_blog_id_from_url() function but no luck Apr 12, 2013 at 6:32
  • I need the details for this site http://192.168.0.89/dev/sareepuram/ss/, but I get the details for the main site http://192.168.0.89/dev/sareepuram/. I used like this $blog_id = get_blog_id_from_url("http://192.168.0.89/dev/sareepuram/ss/"); echo get_blog_option( $blog_id, 'blogname' ); echo get_blog_option( $blog_id, 'blogdescription' ); Apr 12, 2013 at 6:33
  • 1
    Can you add your code in question so that it can help me to find out the problem.. Apr 12, 2013 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.