How To Fix Autoptimize Breaking bbPress Forum Styles
The Fix: Autoptimize Breaking bbPress Forum Styles
Autoptimize has an incredibly powerful and extensive API that allows us to fix this ourselves. This code can be added to the following places:- functions.php file
- child theme
- site-specific plugin
// Fix Autoptimize + BuddyPress
function check_mediatype_bbpress($media, $tag) {
if ( strpos($tag, "bbpress.css") !== false ) {
$media = array("all");
}
return $media;
}
add_filter('autoptimize_filter_css_tagmedia', 'check_mediatype_bbpress', 10, 2);
The above code basically tells Autoptimize that the bbpress.css file should be treated like its media attribute is set to all and then aggregates it into the main stylesheet.
Scott Hartley
Founder & CEO, Sert Media
Founder and CEO of Sert Media, a Nashville-based digital marketing agency. Scott has spent over 15 years helping businesses grow through SEO, web performance optimization, and strategic digital marketing. His deep expertise in WordPress development, site speed, and technical SEO has guided hundreds of brands toward measurable results. When he's not auditing Core Web Vitals or refining campaign strategies, he's writing about the tools, techniques, and trends shaping the modern web.
Related Articles
How to Add Security Headers to WordPress Using Cloudflare Transform Rules
If you've ever run your WordPress site through securityheaders.com and gotten a D or F…
Use This Cloudflare Rule To Reduce Plugin Hack Attempts
Cloudflare Firewall Rules give you a lot of flexibility in further protecting your website. Here…
Set Up Cloudflare's Automatic Platform Optimization Feature
Automatic Platform Optimization (APO) is a new feature from Cloudflare that allows you to cache…