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

Append style tag in head while shortcode runs

I also get this script tag shown in my shortcode output alongside my html that shortcode returns. How can I not have this script tag shown in my shortcode output. Never use echo statement in a shortcode. A shortcode should only return something to display on front-end. As per WordPress Codex : Note that the … Read more

Why is WordPress enqueuing admin relevant scripts (e.g., React, ReactDOM, Redux, hooks, TinyMCE etc) when not logged in?

If your bootstrap or other enqueued scripts have a dependency or name conflict, this could enqueue all these scripts. There are a large number of common scripts in WordPress core that are enqueued under common names. I always recommend prefixing your script names with something specific. wp_enqueue_script( ‘theme-bootstrap’, ‘https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js’, array( ‘jquery’ ), ‘4.3.1’, true );

Are there any caveats to compiling all of my theme’s SCSS into the style.css file in the theme root?

Your theme requires style.css to be present in the theme’s root directory, with a comment header at the top containing information about he theme, like this: /* Theme Name: Twenty Nineteen Theme URI: https://wordpress.org/themes/twentynineteen/ Author: the WordPress team Author URI: https://wordpress.org/ Description: Our 2019 default theme is designed to show off the power of the … Read more