Get wordpress multisite site id

i have a multisite in which people pay to upgrade to adfree. I have a list of blog id’s that are from upgraded sites. I am trying to place code in the page that gets the current blog id but it doesnt seem to work. i am always getting site id 1 returned. Any ideas?

<?php

$current_site = get_current_site();
$id = $current_site->id;
echo $id;
$os = array(267,156, 98,654);

if (in_array($id, $os)) {
echo "dont display ads";
}

?>

thanks

Read More

EDIT. Working Code

 <?php

 global $blog_id;
 $os = array(286,156, 98,654);
 if (in_array($blog_id, $os)) {
 echo "dont display ads";
 }


?>

Related posts

Leave a Reply

1 comment

  1. if (in_array($id, $os)) {
    

    You are missing $ sign from in front of id

    also ensure that $current_site->id does return a number (like 98 for example, not '98,654' string (or float) )