I’ve created a CPT with the arg ‘has_archive’ = true. When viewing the archive or any associated taxonomy pages, fl-builder class is added to the body because the latest post in the CPT has BB enabled. What would be a good way of getting rid of this class on archive and taxonomy pages?
Adding remove_filter('body_class', 'FLBuilder::body_class', 10); removes it initially but it gets added again somewhere else.
This is an outstanding issue that we have yet to figure out. Beaver Builder is set to run whenever it finds a post in the loop that has it enabled, but this has proven to have undesired effects for archives. The problem is, I believe some people are actually using BB on archive pages, so we’ll need to come up with a solution that plays nice in both cases. Right now we’re not sure what that is but we’re looking into it.
but it gets added again somewhere else.
It gets added by the JavaScript as well in case your body tag doesn’t have the body class function. You’ll need to remove this action as well…
Gotcha, thanks for the help. If anyone is wondering, here’s what I did:
add_action('pre_get_posts','remove_bb_classes');
function remove_bb_classes() {
// Check if is CPT archive or taxonomy
if(is_post_type_archive('portfolio_item') || is_tax('portfolio_item_category')) {
// If so, remove calls to add fl-builder to body class
remove_filter('body_class', 'FLBuilder::body_class', 10);
remove_action('wp_enqueue_scripts', 'FLBuilder::layout_styles_scripts', 10);
}
}