functions - Load CSS file conditionally

admin2025-06-04  4

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?

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749022097a315693.html

最新回复(0)