Load CSS file conditionally

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?

Read more here:: Load CSS file conditionally

Leave a Reply

Your email address will not be published. Required fields are marked *