Software Engineering in WordPress, PHP, and Backend Development

Author: Tom (Page 108 of 427)

WP_Query Readability Improvements (For Maintenance)

Working with WP_Query, especially when you’re doing some custom work outside of the usual “get some posts and display them on a template” can be powerful. This is especially true of some of the advanced arguments (like using WP_Meta_Query, for example).

It’s also kind of nice that setting up the process has a standard way of doing things. Namely:

  1. Define the arguments,
  2. Instantiate WP_Query,
  3. Check if there are posts,
  4. Loop through them,
  5. Finish Them.

But if you get to where you’re doing any advanced work such as working with a custom post type from a third-party solution, having to sideload media, determine if something exists before actually doing any work with it, then it can be a little more complicated to work with, can’t it?

I’ve found that, like with anything in programming, breaking it down into much more readable modules (or functions or pieces or whatever you’d like to call them) can make it much easier to work with.

So here’s one way that I go about working to make WP_Query readability improvements in a variety of the stuff I’ve done lately.

Continue reading

Project Guardrails: Writing To Production

In the past few articles, I’ve talked about a couple of things (saved for actually writing to production) that help to run a successful project:

  1. The dangers in “design by committee,”
  2. Considerations for provisioning an environment.

The last thing I want to address the learning I’ve experienced thus far is about maintaining the proverbial keys to the kingdom of writing to production and why that matters.

Continue reading

Project Guardrails: Provisioning Environments

This series of brief articles is made up of a few things I’ve learned over the last few years of running projects based in the area in which we (assuming you’re reading this coming from the same part of the industry I do 🙂) work.

If you’re just stumbling across this, the series is covering some factors that are important for a project:

  1. There should be no “design by committee.
  2. No one else other that the core development team should be able to provision development, staging, and production.
  3. No one should be able to write to production but the development team (and even then, there should be a deployment process).

I don’t really like making hard and fast rules like this namely because things change over time either by necessity or by more experience. This is why I like “guidelines.”

But at the time of this writing, these are the things I see playing out.

Continue reading

Project Guardrails: Design By Committee

When you’re contracted to build a solution for others – primarily on the web since that’s the area in which I work – I think that there are a number of factors that are important for a project:

  1. There should be no “design by committee.”
  2. No one else other that the core development team should be able to provision development, staging, and production.
  3. No one should be able to write to production but the development team (and even then, there should be a deployment process).

I’m always hesitant to make statements like this as they come off as dogmatic, but I find that the longer I work in this industry, the more I think these three rules are important.

Or perhaps they are really just guidelines. After all, there are shots called before we actually get stuff done.

Regardless of if they are more suggestions or rules doesn’t really matter. There are reasons that we all arrive at the conclusions that we do, right? And so over the next few posts (rather than one long post), I’ll share the reasons I’ve found these three rules to be important.

Continue reading

Latitude and Longitude in PHP: A Few Useful Practices

In previous posts, I wrote a good bit about working with the Google Maps API. Truthfully, I haven’t worked with it since that post.

However, I have had to work with latitude and longitude in PHP, and there are some practices that I’ve begun to use that I think can serve us well when working with coordinates or floating point values, in general.

In the following bit of code, I’ll break down the approach I’ve used and why I’ve done so. But I do want to be clear that if you’re reading this in relationship to the Google Maps API, there’s not much I can offer in the way of how this works and the current version of their API.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑