01: Setting up a Local Environment

This is the first lesson in the WordPress Theme Development Course. In this video we cover how to set up a local development environment for WordPress using Local by Flywheel.

If you already have a local development environment set up that you like (using Vagrant, MAMP, Valet, or something else), feel free to skip to the next video. There’s nothing in this series that requires you to use a specific development environment set up. Continue reading

How to Modify the Look of a WordPress Site with CSS

If you want to make a few design tweaks to a WordPress theme (and don’t see an option for it in the Customizer), you’ll likely need to use some custom CSS. Thankfully, WordPress has a great built-in Custom CSS module that allows you to safely add CSS code or override existing styles. This gives you almost unlimited design control over a site!

This video explains how to find the selectors in your theme using the Chrome developer tools and then add your own custom styles in WordPress.

Prevent WordPress Emails in Stage or Local Environments

When you’re developing a WordPress site locally or testing in staging, you’ll generally want to prevent the site from sending out emails to customers or users.

I’ve noticed that a number of other WordPress developers are fans of MailHog (great write up by Jonathan Christopher), but in many cases it’s easier if you don’t have to install anything additional on the server.

I use two plugins to block and then log emails:

“Disable Emails” prevents the emails from sending from WordPress, and “Email Log” is able to capture their contents in case you need to view them.

Since I sync my production environment to staging and local quite frequently, I have a script in my theme that activates these plugins when it detects the new environment.

Using Scroll Reveal for Animation Effects

I’ve been rebuilding a WordPress site that was originally set up using a popular ThemeForest theme and Visual Composer. The theme made it really easy to add animation effects that occur on scroll (as specific elements come into view), but extracting the code for animations wasn’t super easy (it’s part of a 600kb javascript included by theme and mixed with inline styles from Visual Composer).

However, after testing a few different libraries, I found Scroll Reveal worked best as a replacement (3k minified & gzipped). Continue reading

How to Set JSON Endpoints in WordPress to Access an External API

There’s a lot of JSON-based APIs that only provide access through server-side methods. If you want to use client side javascript with one of these external APIs, you’ll need to have your server access the data and serve it through ajax requests or your own JSON endpoint. Thankfully, this is really easy to do with WordPress.

In this example project, I’ll show how to get shipping rates from the Easy Post API with a custom WordPress endpoint. Continue reading

Multiple Domains, Tracking and Third-Party Cookies

Tracking anonymous visitors across multiple domains is difficult because cookies can’t be shared across domains. One way around this is to use an iframe to set the cookie, which works well in Chrome, Firefox, and Edge. However, Safari prevents a challenge because it prevents third-party cookies from being set.

I haven’t found a solution for the Safari issue yet, but thought I’d share the method I’ve worked out for cross domain tracking with Mixpanel for the remaining browsers.

For the example, I’ll use domains a A.com and B.com. A.com is the primary website and B.com is a marketing website that refers traffic to A.com.

On domain A.com you’ll need to set up an URL that loads the tracking code when it’s called inside of an iframe. We can pass tracking data from B.com to the iframe using a query string, and an efficient method for passing that data is by base64 encoding an JSON object. Continue reading