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.

  1. Download the helper plugin zip file, then un-zip it.
  2. Open the PHP file in a text editor.
  3. If you need to exclude a CPT, edit line 28. Replace 
     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');
  4. 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');
  5. 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.
  6. Re-zip the folder.
  7. Install the helper plugin on your site - go to Plugins > Add New > Upload plugin and select the zip file.
  8. Activate the plugin.
  9. Now when you regenerate the Critical Path CSS, these content types will be excluded.
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.