Put php function | WordPress.org

Can i put php function like this using ad inserter, i like this plugin and dont want to create child theme for this function?

function tw_unload_files_except_single_post() {
 
 if ( !is_singular('post') ) {
 wp_dequeue_style ( 'wp-block-library' );
 }
 
 }
 add_action( 'wp_enqueue_scripts', 'tw_unload_files_except_single_post', PHP_INT_MAX );

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer