I'm writing a program in Python that outputs information about Wordpress installations and I'm adding some features to detect Multisite installations and their details. I would like it to print how many sub-installations(?) exist in one multisite, but I'm not sure how to go about that.

I think the built-in Wordpress function equivalent to what I need would be:

return get_site_option( 'blog_count' );

But I need a way to do that without PHP and I can't figure out what query Wordpress is running for that. I figured it would be stored in wp_options but nada.

How I'm getting the count now (example):

$ mysql -e "show tables from $database" | grep -c comments

because I figure each installation is going to have its own comments table. Ideally I'm just looking for a plain number stored in the database somewhere that says how many installations exist.

I'm not a Wordpress person so sorry if I'm scrambling any lingo here. Any help appreciated!

  • WP CLI can do all these things,and in PHP, perhaps you can make use of that ( executing WP CLI commands from python is doable )
    – Tom J Nowell
    Sep 16 '15 at 13:57

The information about the multisite option blog_count is stored in the table wp_sitemeta. Taking a look at the source is in such cases beneficial, if not invaluable.

  • My pleasure! Don't forget accepting the answers that were useful to you. @Respheal
    – Nicolai
    Sep 16 '15 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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