I’ve been using FitVids.js in a lot of recent themes to ensure video displays nicely in responsive layouts. I wrote about this in detail for a previous post.
The FitVids script is super tiny (1.7k), and I generally concat it will all my other scripts and then minify using Grunt. So, it’s really not a lot of additional page weight to include the script. However, I was just clued into an alternate method when doing a theme review for the Make theme on wordpress.org that could be slightly more efficient.
Generally FitVids will only be required if video is loaded via an oEmbed (YouTube, Vimeo). So, if we hook into the oEmbed and already have the FitVids registered to load in wp_footer, we can just enqueue the script when it is needed.
How it Works
I’ve tested it with my most recent theme, and this method works well. If you visit the home page, you can see FitVids is not enqueued. But if you go to the News or the Video Post, you can see that it is.
Loading an extra script requires an additional HTTP request. So, if your theme is being specifically marketed for a video audience- it probably makes sense to just minify and concat. However, if video is just in one or two posts on the site, it might make more sense to use this method.
If you run any type of eCommerce site, it’s important to understand how visitors found your site and which specific entry pages led to a conversion. Tracking data can also let you know the type of content or marketing that is worth investing in.
Here’s a screenshot from a basic eCommerce dashboard I have set up in Google Analytics for a client with a WooCommerce shop (some data changed to make anonymous):
Seeing the top referrers, landing pages, and revenue at a glance is great. But once the eCommerce data is in Google Analytics, you also drill down and answer very specific questions.
For instance, is an ad campaign on one site performing better than another? Should ad traffic be sent to the home page or the shop page? What is the conversion rate (or total revenue numbers) for visitors from Google who landed on an article page via an organic search? Continue reading →
If you’re new to WordPress development, there’s a couple techniques that will be incredibly useful when building themes for a specific company or purpose. Most WordPress themes available are built for general use, but when adapting it for a specific site it’s usually necessary to hardcode at least a few specific elements rather than make everything dynamic.
For example, it might make sense to hardcode the menu if it requires a lot of custom styling. It might make sense to query for specific pieces of known content. Certain pages may have a lot of art direction or targeted styles that would be incredibly difficult to build a custom UI for.
If you’ve already built a few custom themes, it’s likely know a many of these tips already- but hopefully there’s a few gems that will be useful for your toolkit. Continue reading →
It’s taken me a bit of time to figure out the best way to version and deploy sites with WP Engine. I still don’t have a perfect solution, but it’s now much better than using an SFTP GUI to move the files from local to staging.
In terms of version control, I like to have the active theme in its own repository. This is generally where the bulk of custom development work happens, and this makes it easy to view the commit history, open issues, and reference code. If custom plugins are needed for the site, I also like to have those in their own repositories for the same reason.
For everything else on the site (WordPress core, third-party plugins, and media) I think it’s important to have backup points (especially before plugin/core upgrade in case a rollback is required), but I don’t necessarily need to have that versioned with something like Git.
If you’re not like me and prefer to have the entire site versioned in one repository, then git deploys work great with WP Engine. You can even set the gitignore file to ignore specific third-party plugins, media, and core so it just tracks your custom plugins and themes- but those all still need to be in one single repository that is tracked from the root of the WordPress directory. Continue reading →
I’ve been hosting my WordPress sites with Digital Ocean for a few months now. It took me quite a while to learn how to manage everything, and I thought it would be worth sharing a few shortcuts and tricks I’ve picked up.
WordPress 4.1 introduced a new function to display archive pagination as numbered links. Developers have been making this work for long time using custom functions or popular plugins like WP Page Navi, so its great to now have a core function for this purpose. Continue reading →
Working with the command line can be intimidating if you’re used to a nice graphical user interface (GUI), but it’s worth getting familiar with. There’s a lot of mundane tasks in web development can be automated with good set of scripts and shortcuts.
It’s also often much faster and simpler to accomplish a task with the command line, and in this respect WordPress is no exception. WP-CLI makes it possible for you to get your WordPress related tasks done with the help of a set of commands.
You might have a natural question in your mind: if the WordPress admin interface is so gorgeous and user-friendly, why would someone like to use the command line interface? There are two key reasons:
People find keyboard faster than the mouse: Instead of using mouse, a power user always prefer to use keyboard shortcut to accomplish a task. In general, using keyboard shortcuts is 3 times faster than clicking a mouse.
Automation:To make several commands execute automatically, you just need to put them into a single text file. Automation saves a lot of your precious time.
So in this guide, I’m going to give you a taste of WP-CLI: a command line interface for administering WordPress sites. Continue reading →