Skip to content
wp-skills
Register
tools/register-enqueue-styles

Register Enqueue Styles

WordPress Register Enqueue Styles Generator is a tool for dynamically adding and managing customized style files to WordPress theme.

Give it a prefix of your own. Two snippets sharing a function name is a fatal redeclaration.

Which screens the stylesheets load on. Each is a different hook, and the front end and the admin do not share one.

Stylesheets1
  • #1

    The handle. It is what other stylesheets list as a dependency, and what wp_add_inline_style() addresses.

    How the source is resolved. A child theme's own assets are not under get_template_directory_uri() — that points at the parent.

    A leading slash is optional; both spellings produce the same URL.

    Comma-separated handles. These are loaded first, which is how you make sure your rules come after the ones they override.

    Appended as ?ver= and is what busts a browser cache. false uses the WordPress version, which changes on every core update.

    The media query the browser applies this under — all, screen, print, or a query of your own.

snippet.php
function my_enqueue_styles() {
	wp_enqueue_style(
		'my-style',
		'https://example.com/my-style.css',
		array(),
		'1.0.0',
		'all'
	);
}
add_action( 'admin_enqueue_scripts', 'my_enqueue_styles' );