Display Posts or Pages Based on a Navigation Menu

For a site I’ve been working on there’s a section of “featured content” near the bottom of the home page. I was using a simple WP_Query to generate the markup, but after the third time updating the post IDs (because different content needed to be featured), I decided this needed to be managed somehow through the dashboard.


The most common way to do something like this is generally to have a WP_Query that pulls from a specific taxonomy term (like a “featured” tag), however this doesn’t give you any control over the order of the posts. Also, in my case, I needed to display pages and a custom post type “guide” in addition to standard posts.

Thankfully, the WordPress Navigation Menus provide an easy built in interface that can be used to select content. So, I swapped my hardcoded query to pull Post IDs from a navigation menu instead. I thought it would be worth sharing the solution since this could be used in many types of situations: sliders, setting featured products for a specific template, or featuring content in a sidebar or footer. Continue reading

Shopify vs. WooCommerce


A former client contacted me this week because they were thinking about switching platforms for their ecommerce store. The site had originally been built on WooCommerce but they were now considering a switch to Shopify. The main issue is they didn’t want to have to rely on a developer for site updates and wanted a solution they could more easily manage themselves.

To answer their questions, I signed up for a Shopify account and then went through the technical and business requirements one by one. If you’re trying to decide between Shopify and WooCommerce, hopefully some of these notes are useful. 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

Working with the Mixpanel API


We use Mixpanel at Cratejoy to track a lot of user interactions across the sites. However, there was a lot of profile data we were storing (and paying for) that we weren’t actually doing much with. So, I decided to see if it was possible to back up this data locally, create re-import files (in case we ever needed it again), and then delete in bulk.

Here’s some notes and tips about that process. Continue reading

Theme Update Script for Custom Logo

I’ve been updating several of my themes to support the new custom logo feature that is being introduced in WordPress 4.5 (read about it here).

Most of my themes already had a logo option, so part of adding support for this new feature has been to build an update script to migrate the previously saved value (generally saved to the theme mod “logo”), to the new theme mod “custom_logo”.

I assume a lot of other theme authors will also be doing this, so I’m sharing my update code in case it can save someone a few minutes. Continue reading


I’ve started using DeployBot to manage a lot of my code deployments. It works great if you develop custom themes for clients and keep your repositories in hosted version control (like GitHub or BitBucket).

I generally work in a “staging” branch (when I’m working solo), which auto-deploys to the staging environment. I trigger deploys to production with commit messages to the master branch, i.e. “Version 1.2.2 [deploy production]”.

One really nice feature Deploybot added recently is the ability to run build tasks on a cloud server before transferring via SFTP to the final destination. This means you can keep generated assets (sass files, minified js) out of your git repos, which keeps the committed changesets cleaner and avoids generated code conflicts when working with teams.

The only issue I had when using build tasks with deployments was this occasional error “DeployBot failed to establish or maintain connection to your server.” I found if I added “rm -rf node_modules” as the last step in the build, that resolved the issue. It also sped up the deploy and kept those files off the destination server.

If you’re interested in how other WordPress agencies/freelancers use Deploybot, this post highlighting Reaktiv is also a nice resource.

Query by JetPack Related Posts

A site I’ve been working on had a list of “recent posts” displaying underneath the main content. The feature used a WP_Query loop to display an image, title, and author link for each recent post.

The client wanted to update this to use a “related posts” algorithm instead, but didn’t want to change anything else about the design or display. That got me curious if it would be possible to fetch the IDs from the Related Posts module in JetPack, but then run them through WP_Query to output the existing custom markup. Continue reading

How to Overwrite a Theme

If you’re trying to install a theme update manually, you might get this message:

Installing the theme…
Destination folder already exists.
Theme install failed.

In order to update the theme, you’ll actually need delete the current version before you can upload the new one.

Here’s how to do that:

  • Go to “Appearance > Themes”
  • Temporarily switch to an alternate theme
  • Then, click “Theme Details” for the theme you are trying to replace
  • Click the “Delete” link in the bottom right
  • Now click the “Add New” button and upload the new theme version
  • Switch to the new version of the theme you uploaded