Yes, you can use the body_class
filter. If all the sites use the same theme, you can get away with putting this in functions.php
(in a child theme so your code doesn’t get overwritten when the theme is updated), but if any sites have a different theme, you’ll need to put it into a custom plugin (perhaps a MU plugin).
<?php
add_filter('body_class', 'wpse_299000_body_class');
function wpse_299000_body_class() {
// check if current subsite is inactive, deleted, archived, or spammed
$is_inactive = ms_site_check();
// value will come back either true or false
if($is_inactive == true) {
// add your desired class to <body> - this example adds .inactive
$classes[] = 'inactive';
}
// always return classes so none are taken away
return $classes;
}
?>
You can also remove classes if needed.
Related Posts:
- How to load scripts/styles specific for a page
- Prevent “main” WPMU site_url() being returned in functions
- functions.php inject inline css
- How do I create a new WP admin color scheme?
- Logout/login redirect CSS issue
- Implementing DNS Prefetching with WordPress
- Add attribute to link tag that’s generated through wp_register_style?
- TinyMCE custom stylesheets for different post types
- Remove “says” from comments
- How to add CSS style sheet dynamically in wordpress
- Simple/basic use of get_current_screen
- Is it possible to be more page/post specific with admin_enqueue_script?
- Child Theme Not Overriding Parent Theme
- CSS stylesheet not loading
- Enqueue styles after a plugin
- How to add background image control to page admin controls?
- Delete pages and Create default pages for all new network sites
- Multisite, either change the name of sample-page or create new page
- Global functions on WPMU
- Add class or ID to any WordPress function
- restore_current_blog required after switch_to_blog, if I use that in a function?
- Register and enqueue style.css custom theme
- Multiple CSS body classes to specific page I.D.’s – is this possible?
- Enqueue Style Only On Certain Pages Not Working
- Why does the ‘wp_nav_menu’ function work only until a menu is created?
- Run function when WordPress new multisite is created or ACF field is updated
- How to Display Frontend CSS for Administrator only
- WordPress Menuing Question :focus
- change the url paths in the stylesheet dynamically
- Please Explain the Importing Process of Multiple Stylesheets for Child Themes
- Conditional Gravity Forms filter in WordPress Multisite
- Multisite Ajax serialize return error [object Object]
- Creating new blog on multisite programatically without hacks?
- How to get correct URLs in network wide menu (Multisite)?
- Multisite 404 on pages – rewrite error breaks database
- Change CSS for logged in users
- Has is_archived() for sites in a multisite changed with WP 4.7?
- Redirect to another page using contact form 7? [closed]
- Function that outputs second theme url
- different style sheet for just one page template
- Custom styles.css sheet for visual editor
- Is my code correct to enqueue CSS on a specific page?
- Not all CSS elements transferring via parent to child?
- Split Media Queries in different files!
- Some questions about how proper add 2 CSS file in a WordPress theme?
- problem loading stylesheets to wp_head dynamically
- How to insert class in each list of categories?
- Parent theme styles overriding child theme CSS [closed]
- I can’t add CSS with functions.php
- Theme JS is available but theme CSS isn’t
- Proper Way to Load stylesheet on Condition
- This code works, but the way I integrated it is breaking the media uploader. How can I integrate it properly?
- Default Nav Highlight
- Custom styles in Tiny MCE with an external CSS file
- why can’t i add front.css to my frontpage.php
- get_template_directory_uri() links to child theme not parent
- remove/hide wp-editor
- Page Template Won’t Load Correct CSS File
- wp_get_attachment_image_src returns image on main domain, false on subdomain
- current_page_item is missing inside wp_nav_menu
- functions.php return custom text
- define css class in functions.php
- Dashboard blocker on network multisite for specific user roles
- Completely Disable WordPress RSS Feeds
- Members only function, but allow account activation [solved]
- Combine page types and Custom Taxonomy in a functions.php command
- Can’t load assets
- How to reference different css (bootstrap) stylesheets for the header and body of a page?
- Can we have conditional CSS styling?
- CSS style and app.js not loading
- Post content overflows on my mobile phone
- Stylesheet does not load despite functions.php
- Remove clickable Link of WordPress Site Logo from Woocommerce Single Product page
- How do I make a custom “Read More Blogs” button for my blog page
- function class doesnt work
- Help using ShortCodes to style whole chunks of the post
- Competing Login Redirects – Need to be Combined?
- Setting Up Child Theme To Take Priority
- how to remove a tag in the_category function
- CSS disabled after getting rid of emoji
- How to add styles in existing function?
- Woocommerce – Switching Price for Category
- Conditionally apply css for a specific template part
- Child Theme not loading multiple stylesheets
- Correct way of Enqueue self hosted fonts in sass project
- How to automatically add custom classes to headings in content area
- Changing the color of post title [closed]
- Random text changing to weird icons in both admin & front end
- Functions.php in child theme that loads CSS file breaks website
- Syling Custom Fields echo’s from from functions.php
- functions.php / replacing div’s with new ones?
- Run function from parent on child site
- Should I use `get_stylesheet_uri()` or `get_template_directory_uri()` when calling my CSS Stylesheet?
- How can I append and prepend something to all post hyperlinks without using ::before or ::after? PHP hook solution?
- Image width issue in IE [closed]
- How do I make my child theme’s CSS update when I save it?
- Why don’t ‘wp_nav_menu’ CSS classes work until a menu is created?
- Ads Only at one website inside multisite network – code error
- Different ads on every website on multisite environment
- wp_head not injecting css