How can I get this child theme stylesheet to properly load? Or if it is correct, why doesn’t my child theme appearance match the parent?

I think you need to declare the bootstrap dependency when you enqueue the parent stylesheet (bootstrap.css is enqueued by the parent theme). The parent theme doesn’t declare the dependency but enqueues style.css after bootstrap.css, so it “just” works. But when you change the order of the enqueue, the dependencies are broken. Use the third parameter … Read more

enqueing Javascript and CSS

If you care about pagespeed and those standards, you should make the resources local instead of off remote servers. Although they’re all off CDNs, nothing’s faster than local. With http/2 on the rise, its going to become less and less important to have fewer scripts- but having them locally will still matter. You can combine … Read more

Enqueueing styles with version variable

Try this // global theme version $version = ‘1.0.0’; function frontend_styles() { global $version; wp_enqueue_style( ‘frontend_styles’, //reference get_stylesheet_directory_uri() . ‘/assets/css/app.min.css’, //source array(), //dependenices $version, //version number ‘all’ //media type (‘all’, ‘screen’, ‘handheld’, ‘print’) ); }

Apply function only if end of url has /amp/ [closed]

In your example, $_SERVER[‘REQUEST_URI’] would return /category/post-slug/amp/ which is not the same as get_permalink($post->ID) which would return https://example.com/category/post-slug/ There are lots of ways to go about this, but one easy one that comes to mind is… if ( strpos($_SERVER[‘REQUEST_URI’], ‘/amp/’ ) !== false ) { The strpos() PHP function finds the position of 2nd string … Read more

Page Templates not using functions.php

Your enqueued css should work for all page template if there is no condition applied. could you please share it how you enqueued? Another thing you can check. In header.php, can you please check that wp_head(); function has been called properly in the page template’s head tag. if not exists in the header.php between the … Read more

Stylesheet Enqueue Order and Best Practices

You can simply make your plugin css dependent upon the theme css and the child theme css dependent upon the plugin css. function wpdocs_custom_scripts() { // example theme style wp_enqueue_style( ‘theme-style’, ‘#’ ); // Plugin css wp_enqueue_style( ‘plugin-style’, ‘#’, array( ‘theme-style’ ) ); // see “theme-style” passed in $deps param, // Child theme css wp_enqueue_style( … Read more

how to load css and js based on post template

It looks like your condition check is correct. As per the comments to the question, don’t forget to add it as a callback to the wp_enqueue_scripts action hook. function enqueue_styles_and_scripts() { if ( is_page_template(‘htmlcode.php’) ) { wp_enqueue_style( ‘code-mirror-css’, get_template_directory_uri() . ‘/code-mirror/plugin/codemirror/lib/codemirror.css’, array(), ‘all’); wp_enqueue_style( ‘code-mirror-monokai’, get_template_directory_uri() . ‘/code-mirror/plugin/codemirror/theme/monokai.css’, array(), ‘all’); wp_enqueue_script( ‘code-mirror-js’, get_template_directory_uri() . ‘/code-mirror/plugin/codemirror/lib/codemirror.js’, … Read more