Styling Blog Post through template ID


Hi folks,

i want to apply custom css via child theme to specific pages and all blog posts.

For me the easiest solution was to create a new custom page template in the child theme, set the specific pages to this template in the regular wordpress editor (not elementor) and then add a function in the function.php to target these specific pages to the custom css:
wp_register_style( ‘whiteBG_nonE’, get_stylesheet_directory_uri().’/white_bg.css’);

function whiteBG_nonE_scripts() {
    if(basename(get_page_template()) == 'white_bg.php'){
add_action('wp_enqueue_scripts', 'whiteBG_nonE_scripts');

For the Blog posts, i want all Blog posts to get targeted to the same

In the child theme i created style as registered before.
And yes, i could solve this by creating a template in Elementor, but 90% of the Blog posts will be created in the regular wordpress editor so this isn’t an option right now.

function whiteBG_Post_nonE_scripts() {
	if ( '1' == jupiterx_get_post_single_template() ) {

So i tried to get the template-ID from the regular Post I’m using and apply the Style, but it didn’t work…

I’m thankful vor every tip!