To do that, I use this trick to determine the URL for the script relative to the file:
$file = dirname( __FILE__ );
// Get the URL and path to wp-content
$content_url = untrailingslashit( dirname( dirname( get_stylesheet_directory_uri() ) ) );
$content_dir = untrailingslashit( WP_CONTENT_DIR );
// Fix path on Windows servers
$file = wp_normalize_path( $file );
$content_dir = wp_normalize_path( $content_dir );
$uri = str_replace( $content_dir, $content_url, $file );
* This snippet was updated 02/11/16 based on code from Duluxe Blog Tips, which fixes issues with relative loading in Windows server environments.
Of course, if you do know the path to the JS file, it’s recommended you use:
There are a number of methods to load Google fonts in a WordPress theme, but some are more efficient than others. Google has a post about optimizing the use of the Font API. I thought I’d summarize this as it applies to WordPress themes.
Enqueue or @import?
One of the simplest ways to load Google fonts is to do a an @import from the stylesheet, but Google recommends to link directly from the head of the document instead.
Properly enqueing the font and loading it from the head will also make it easier for people using child themes to change the font without copying the entire parent stylesheet over. Continue reading →
The learning curve on Thematic is a bit steep if you’ve never used filters and hooks before. So here’s my growing list of Thematic filters for easy reference. Replace the title with a logo, add Google Analytics code, change the footer and more.
“WordPress takes care of 80-90% of (the mechanics of ) Search Engine Optimization (SEO)”. So by using WordPress, you are already better positioned for search than the majority of websites. But what else contributes to page rank and search optimization?