Tom McFarlin

Software Engineering in WordPress, PHP, and Backend Development

Page 282 of 428

Passing Variables in WordPress: WP_Query

Check out the second post on passing variables in WordPress in loops.

One of the most minute aspects of writing code is opting when – or when not – to use variables.

It sounds like a trivial decision, right? And in some respects, it is, but the longer I’ve been writing code (or, perhaps a better way to put it), is that the more code that I’ve written and had to maintain, the more my opinion has changed on how frequently I use variables.

After being in the industry for a couple of years, I tried to follow the this rule of thumb:

“Only if I need to use this value more than once, then I will store it in a variable.”

And I still think that’s a decent rule of thumb, but the more I’ve worked with systems that, say, interface with a database, or that leverage multi-dimensional arrays, or that some type of iteration (be it an each iterator, a foreach iterator, or something similar), the more I’ve found how storing a variable – even if it’s only going to be used once – can make for slightly more readable code.

Continue reading

Coding Standards and Guidelines (“When in Rome, Program Like the Romans”)

Recently, I was talking with a fellow developer about the various strategies there are for writing code.

By that, I mean we’ve got a number of different paradigms such as object-oriented programming, functional programming, and procedural programming. We’ve got design patterns, strategies, ideas like SOLID, domain-driven design, aspect-oriented programming, and so on.

When it comes to these things – and as with most things – developers can be really opinionated (myself included) about which things are the best to use. To some degree, I think that there’s some part of us that wants to believe the thing that we’ve just learned is “the next great thing” as it relates to writing code.

Maybe that’s an amateur’s mistake, though. I mean, that’s how I felt earlier in my career – I remember whenever I learned, say, domain-driven design and all of the stuff that comes with it, I wanted to implement in all of my future projects because I thought it makes the code so much more readable.

But over time, my opinions have changed.

Sure, I still really like certain aspects of all of the aforementioned programming techniques, but I also know that I can’t apply them all in what I’m doing.

Continue reading

Organize WordPress Terms in Alphabetical Order

I’d argue that, at this point in time, working with WordPress taxonomies has never been easier.

Sure, creating, tagging or categorized, and adding custom taxonomies to posts and custom post types has always been relatively easy, but when it comes to implementing a solution that utilizes custom post types and/or custom taxonomies, then constructing queries can sometimes be a bit of a pain.

But now, we have more API functions and features than ever before:

Of course, there are still cases in which retrieving and organizing data still leaves something to be desired. 

I don’t fault WordPress for this, though. It’s more of a function of how data is ordered within databases, applications, and in computers in general.

Continue reading

Everything is Important, Not Everything is Urgent

During one of my first jobs working in software, I was responsible for working on the functionality that allowed the front-end to talk to the middle-ware asynchronously.

That sounds way fancier than it really is, right?

Trying to write fancy words, like a sir.

Trying to write fancy words, like a sir.

Basically, I was doing a lot of Ajax. Of course, at the time, it was really cool stuff because it was while Ajax was become more mainstream, and the product on which I was working was using Prototype, and had a lot of neat stuff going on.

But whenever you end up using a new technology, and they are supported in a variety of ways in different browsers, then you’re bound to have edge cases that your users catch that are not caught by you or your testing department.

And if you deeply care about the stuff on which you’re working, getting support tickets for the things on which you’ve worked can sometimes be a major downer.

Continue reading

Should WordPress Editor Styles Be Required For Premium Themes?

At this point, there are a number of great content management-related features that are built directly into WordPress that are easy for theme developers to employ.

Some of these features include:

  • Enabling post formats
  • Automatic feed links
  • Setting the default content width
  • Opting to enable (or disable) featured images
  • …and so on.

And many of these features are widely used by a variety of different themes. Obviously not every theme uses all of the above functions but many use some of them.

But there’s one native feature that, for one reason or another, doesn’t seem to have taken off as much as other features:  WordPress editor styles.

This is a bit odd to me, because I think it’s one of the features that can greatly enhance the experience with a theme, and I think it can contribute to create greater differentiation in premium-grade products.

Continue reading

« Older posts Newer posts »

© 2026 Tom McFarlin

Theme by Anders NorenUp ↑