HTML and CSS Reference
In-Depth Information
When we create a bespoke WordPress theme for a client, we develop it as a child theme of
our framework. In the framework itself, we register a number of JavaScript and CSS files in
accordance with our naming convention.
In the child theme, we then simply enqueue files to output the HTML.
function clienttheme_enqueue_css () {
if ( ! is_admin ()):
wp_enqueue_style ( 'theme-mobile' );
wp_enqueue_style ( 'theme-desktop' );
wp_enqueue_style ( 'theme-desktop-ie' );
endif ; //!is_admin
add_action ( 'wp_print_styles' , 'clienttheme_enqueue_css' );
function clienttheme_enqueue_js () {
if ( ! is_admin ()):
wp_enqueue_script ( 'theme-custom' );
endif ; //!is_admin
add_action ( 'wp_print_scripts' , 'clienttheme_enqueue_js' );
Adding CSS and JavaScript to our themes the WordPress way enables us to keep track of
exactly what's going on at a glance.
A Slight Limitation
If you use a JavaScript framework in your theme or plugin, then you're stuck with the version
that ships with the current version of WordPress, which sometimes falls a version or two
behind the latest official release of the framework. (Upgrading to a newer version of the
framework is technically possible, but this could cause problems with other themes or plugins
that expect the version that ships with WordPress, so I've omitted this information from this
While this prevents you from using any new features of the framework that were added after
the version included in WordPress, the advantage is that all theme and plugin authors know
which version of the framework to expect.
Search WWH ::

Custom Search