Programmatically Adding a Menu Item to a WordPress Menu

Just today I had to add a logo to a WordPress menu on a site I was working on. Because it is a graphic that I needed to add, I couldn’t easily use the default WordPress menu functionality to accomplish this. One possible workaround, I think, could have been to add a class to the…

Importing a MySQL Dump with Bad Dates

A problem that I run into fairly regularly when transferring older sites to my local environment is that, when importing the MySQL dump, I get an error like: ERROR 1292 – Incorrect date value: ‘0000-00-00’ It seems that, prior to version 5.7, MySQL used to allow invalid dates like 0000-00-00. However, this behavior changed in…

A Fallback for Ray

As I mentioned in a previous article, I really like using Ray for debugging as I develop WordPress projects. However, one thing that can be easy to do is to forget to remove all of your calls to ray() and upload to a production site where the Ray plugin is not installed. Then… ack! An…

Using an SVG Icon for a WordPress Custom Post Type

When creating a Custom Post Type in WordPress there is a convenient way to select a custom icon when registering the post type. WordPress comes with a set of built-in icons called Dashicons that have easy names that can be used for your menu_icon property: Having these icons at hand is great. Unfortunately, I often…

Creating a Rewrite Rule in WordPress

Recently I had to create an endpoint for users to view a dynamically-generated PDF on a site. I wanted to have a nice-looking URL for users. I found it difficult to wrap my head around the process of adding a rewrite rule in WordPress but I finally figured it out. WordPress offers a function, add_rewrite_rule,…

Passing PHP Variables to JavaScript in WordPress

One thing that I found difficult to understand when starting out with WordPress development was how to use PHP variables in my JavaScript. I’m not sure why I found it so confusing. There are a lot of good examples out there but I thought I would break down how use PHP variables in your JavaScript…

Transferring a WordPress Site from One Server to Another

One thing that I have to do fairly frequently is to move a WordPress site from one server to another. Examples of this can be moving a site from staging to production or production to my local environment. There are a lot of ways to do this but I thought I would document my process….