Software Engineering in WordPress, PHP, and Backend Development

Category: Articles (Page 46 of 258)

Personal opinions and how-to’s that I’ve written both here and as contributions to other blogs.

Custom Archive Templates: A Short Guide

Whenever you’re working with archive templates in WordPress, posts are typically listed by date in descending order. That is, the most recent posts are listed at the top, and then it goes from there.

Lately, I’ve been working on a few projects that integrate with third-party APIs. These APIs return dates – sometimes two dates, a start date, and an end date – for a given event and customers want to use that information to list posts rather than the date of the post. That is, they want custom archive templates.

It’s not too hard to do this, but before doing so, I think it’s important to give some background information on how the project is built so there’s a bit more context around why, say, a custom query is needed and why you may or may not need to look into pre_get_posts.

I’ll start with a TL;DR first, though. That way, you can get the idea before reading the whole thing.

Continue reading

WordPress Widgets: Refactoring, Part 3

In terms of updating the WordPress Widget Boilerplate (all of which is tracked in the develop branch), we’ve come a long way in terms of refactoring how it’s organized.

WordPress Widget Boilerplate: The Develop Branch

Thus far, we’ve:

Now we’re ready to start refactoring this code in a much more object-oriented manner.

So if you’ve yet to catch up with the previous posts (any of them, really), I recommend doing so because it’s going to take a little while to bring this up to date. There’s a lot of code to write an explain.

Let’s get started.

Continue reading

WordPress Pagination: A Simple Utility (And Why)

When building templates for WordPress, you generally have pagination functions that come from the application itself.

WordPress Pagination: Get Next Post

These incude things like:

And there are a few other posts that give you greater granularity around taxonomies such as get_adjacent_post().

I recommend reading all of the above links because they are useful if you’re building a theme, working with custom post types, or are simply looking for a deeper understanding of some of the common template tags.

If, however, you’re looking for an easy way to write your WordPress pagination utility (which I’ll explain the rationale for momentarily), then the rest of this post will cover exactly that.

Continue reading

WordPress Widgets: Refactoring, Part 2

After all of the preliminary content, we are finally at a place where we are ready to begin resolving the coding standard problems thrown by our IDE and by our code quality tools.

In doing this, I’m going to be breaking down the content into two posts:

  • the first post is going to focus solely on refactoring the existing code,
  • in the next post, we’re going to look at refactoring the structure of the plugin to enhance the organization and architecture.

Screen Capture on 2018-11-20 at 12-50-27.gif

For now, though, let’s take a look at the errors the code sniffer is throwing and see if we can’t bring it up to more modern standards.

Continue reading

Keeping Domains, Hosting, and Email Separate

Though this is something I think anyone with a domain, self-hosted site, and email should use, it’s also something I think is important for us – as those who provide services to others – should use.

Specifically, I’m talking about keeping domains, hosting, and email separate so if you opt to change, say, your hosting then you can keep all of the parts working with as little downtime as possible.

In this post, I’m going to cover how to do it, the services I recommend (and no, none of these are affiliate links), and then how each piece works independently of one another to provide the most seamless experience possible.

Continue reading

« Older posts Newer posts »

© 2026 Tom McFarlin

Theme by Anders NorenUp ↑