Prevent Critical CSS generation for custom post types and taxonomies
When using Load CSS Asynchronously, you may see errors when trying to generate CSS for custom post types (CPT) and taxonomies that are not publicly accessible. In this case you can exclude them from the CSS generation.
๐ Manual code edit required before use!
๐ฅ Download (.zip): WP Rocket | Exclude Post Types and Taxonomies from CPCSS generation
Developers: You can find the code for this plugin on GitHub.
- Download the helper plugin zip file, then un-zip it.
- Open the PHP file in a text editor.
- If you need to exclude a CPT, edit line 28. Replace
post_type_to_exlude
with the name of your CPT.
If you don't want to additionally exclude a taxonomy, comment out line 48 by adding a double // at the beginning, like this:
//add_filter( 'rocket_cpcss_excluded_taxonomies', __NAMESPACE__ . '\wp_rocket_exclude_CPCSS_taxonomies');
- If you need to exclude a taxonomy, edit line 43. Replace
taxonomy_to_exlude
with the name of your taxonomy.
If you don't want to additionally exclude a CPT, comment out line 33 by adding a double // at the beginning, like this:
//add_filter( 'rocket_cpcss_excluded_post_types', __NAMESPACE__ . '\wp_rocket_exclude_CPCSS_CPT');
- If you want to exclude both a CPT and a taxonomy make sure lines 33 and 48 do not have a double // at the beginning.
- Re-zip the folder.
- Install the helper plugin on your site - go to Plugins > Add New > Upload plugin and select the zip file.
- Activate the plugin.
- Now when you regenerate the Critical Path CSS, these content types will be excluded.