Styling best practices for single pages/templates
Styling best practices for single pages/templates
Styling best practices for single pages/templates
I believe your mistake is using main as handle keyword for both script and style, handle must be unique. You don’t have to use wp_register_script (and style) enqueue function does this automatically. You typically use wp_register_script(style) only if you are not sure if script/style will be needed later, if it is enqueued conditionally, but you …
You can use content_url() to get a URL to the wp-content folder: add_action( ‘init’, function() { wp_enqueue_style( ‘my-tag’, content_url( ‘cssfile.css’ ) ); }); See https://developer.wordpress.org/reference/functions/content_url/
Your php code block is not properly formated. You currently have this <php? wp_head(); ?> Notice the opening php tag <php?, a correct php tag is <?php. A less than symbol < followed by a question mark ? followed by the word php. So a proper php block would look like this <?php // Your …
WordPress uses jQuery in a noConflict mode. Use it like this: (function($){ /** * Immediate execution */ console.log(); /** * When DOM is ready */ $(document).ready(function(){ }); /** * When all content is loaded */ $(window).load(function(){ }); // window.load END })(jQuery);
Custom theme – Bootstrap CSS not loading via wp_enqueue_style or otherwise
You may also want to try to deregister the style within your function since it has been register in the parent theme function. Try: function remove_google_fonts_stylesheet() { wp_dequeue_style( ‘pixgraphy_google_fonts’ ); wp_deregister_style(‘pixgraphy_google_fonts’); } add_action( ‘wp_enqueue_scripts’, ‘remove_google_fonts_stylesheet’, 100 );
Should I use wp_register_style(), wp_enqueue_style, or both?
I think you can try with this code below. function childtheme_enqueue_styles() { wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’, array(), wp_get_theme()->parent()->get(‘Version’) ); wp_enqueue_style( ‘child-style’, get_stylesheet_uri(), array( ‘parent-style’ ), wp_get_theme()->get(‘Version’) // Note you must provide a version into the child theme ); } add_action( ‘wp_enqueue_scripts’, ‘childtheme_enqueue_styles’ );
The fix was really easy. The template I was trying to load, did not have wp_head() in it. So ofcourse no JS/CSS was loading in. Thanks for the help everyone!