Load CSS file conditionally

by Michael   Last Updated January 11, 2019 12:08 PM

Trying to load CSS file conditionally – only for specific pages with the following:

add_filter('tablepress_use_default_css', 'tablepress_css_conditional_load');
function tablepress_css_conditional_load($load) {
return ((!is_page(array( 229, 9 ))) ? false : $load);

For some reason it is not working. To make sure that there is no mistake in the IDs I replaced "! is_page( array( 229, 9 ) )" with "! is_page()" and with "! is_single()" but still it is not working. Deactivated other plugins, changed theme, still nothing. The CSS name is verified with the plugin author. When the above part is replaced with “is_single()” the code works in a way that lets the CSS load for any page – not for posts. However the point is to load only for the named pages. Which is the correction needed?

Tags : functions

Related Questions

Updated March 26, 2015 11:02 AM

Updated April 04, 2015 19:03 PM

Updated April 05, 2015 18:03 PM

Updated May 18, 2015 09:03 AM

Updated May 29, 2015 03:03 AM