wharfdale
wharfdale

Reputation: 752

WP - Check if current site matches site_id

I am trying to check if the current MU site_id is 389 or 545 and then load the custom fonts file.

This is my attempt to check if either of the 2 site_id's provided match what is in the $site_id variable. No errors returned, it's just not matching and not loading the file. Anything obviously wrong?

$site_id = get_current_blog_id();

if( $site_id == array('389', '545') ) {
      wp_enqueue_style('sage/custom-fonts.css', asset_path('styles/custom-fonts.css'), false, null);
    }

This works fine:

if( $site_id == '389' ) {

But I want to check multiple ID's.

Upvotes: 1

Views: 218

Answers (1)

Tamilvanan
Tamilvanan

Reputation: 718

Let's try the below code.

$site_id = get_current_blog_id(); // Returns Integer
$site_id_arr = array('389', '545');
if( in_array($site_id,$site_id_arr)) {
    wp_enqueue_style('sage/custom-fonts.css', asset_path('styles/custom-fonts.css'), false, null);
}

Ref:

in_array

get_current_blog_id

Upvotes: 2

Related Questions