Proper Enqueuing of Child Theme; Removing Query Strings
-
I created a child theme for customization by enqueuing it in functions.php:
<?php function my_theme_enqueue_styles() { $parent_style = 'twentynineteen-style'; // This is 'twentynineteen-style' for the Twenty Nineteen theme. wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' ); wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( $parent_style ), wp_get_theme()->get('Version') ); } add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' ); ?>
Upon creating the file, I inserted additional code below to remove query strings from static resources, which I often put in other themes to enhance speed.
//* TN - Remove Query String from Static Resources function remove_css_js_ver( $src ) { if( strpos( $src, '?ver=' ) ) $src = remove_query_arg( 'ver', $src ); return $src; } add_filter( 'style_loader_src', 'remove_css_js_ver', 10, 2 ); add_filter( 'script_loader_src', 'remove_css_js_ver', 10, 2 );
Unlike other themes, the string removal code shows up above the header of the site. I removed it at this time. Did I enqueue the child theme properly?
Thanks!
- This topic was modified 6 years, 2 months ago by .
- This topic was modified 6 years, 2 months ago by .
The page I need help with: [log in to see the link]
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Proper Enqueuing of Child Theme; Removing Query Strings’ is closed to new replies.