Load js/css files only on specific admin UI pages

The right hooks // Use both for scripts & styles *) wp_enqueue_scripts // (for the frontend) login_enqueue_scripts // (for the login screen) admin_enqueue_scripts // (for the admin dashboard) *) Read this article @wpdevel. Further reading in the Codex about the three hooks admin_menu network_admin_menu user_admin_menu On the admin_enqueue_scripts hook, you have an argument as well: … Read more

Enqueue custom font file with rel=”preload”

You could try using the style_loader_tag filter. add_action(‘wp_enqueue_scripts’, ‘my_enqueue_scripts’); function my_enqueue_scripts() { wp_enqueue_style(‘my-style-handle’, “https://wordpress.stackexchange.com/fonts/custom-font-folder/CustomFontFile.woff2”, array(), null); } add_filter(‘style_loader_tag’, ‘my_style_loader_tag_filter’, 10, 2); function my_style_loader_tag_filter($html, $handle) { if ($handle === ‘my-style-handle’) { return str_replace(“rel=”stylesheet””, “rel=”preload” as=”font” type=”font/woff2″ crossorigin=’anonymous'”, $html); } return $html; } Here we’re enqueuing the stylesheet using the normal wp_enqueue_style function. We then capture the … Read more

Loading a child-theme’s style.css after the parent’s

As @Andy Macaulay-Brook pointed out WordPress doesn’t load child-theme’s style.css . I guess parent theme might be en-queuing it. De-queue the child-theme style.css first and then enqueue it En-queue parent’s style.css before child theme’s style.css De-queue the child-theme style.css You can de-queue the child-theme’s style.css by using the handle.You can find out the handle either … Read more

How does one load style.css into a theme?

Make sure you have the files named and labeled correctly and in the right place. functions.php located @ mytheme/functions.php <?php /** * Theme Functions */ function theme_name_scripts() { wp_enqueue_style( ‘style-name’, get_stylesheet_uri() ); wp_enqueue_style( ‘style-name’, get_stylesheet_uri() ); } add_action( ‘wp_enqueue_scripts’, ‘theme_name_scripts’ ); style.css located @ mytheme/style.css /* Theme Name: Twenty Thirteen Theme URI: http://wordpress.org/themes/twentythirteen Author: the … Read more

What is the correct way to enqueue multiple CSS files?

The wp_enqueue_style() function uses the following format and parameters: wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false, $media=”all” ); In your case, you could try the following: <?php /** * Proper way to enqueue scripts and styles */ function namespace_theme_stylesheets() { wp_enqueue_style( ‘mamies-wafers-bootstrap-min’, get_template_directory_uri() .’/css/bootstrap.min.css’, array(), null, ‘all’ ); wp_enqueue_style( ‘mamies-wafers-carousel’, get_template_directory_uri() … Read more

Issues enqueueing parent & child theme stylesheets with revised Codex method

QUESTION 1 Is it safe to include the assumption that parent themes properly enqueue the child theme styles, from the standpoint of child theme standards? General rule of thumb, yes. But, you should never assume. Most disasters and failures in live are due to assumptions or facts based on an assumption FACTS WITHOUT ASSUMPTIONS A … Read more