Tom McFarlin

Software Engineering in WordPress, PHP, and Backend Development

Page 233 of 427

A Guide To Branching (Based in Git)

Whenever we introduce others to a new technology, service, application, or anything else, I think that we – as developers – don’t often do such a hot job of showcasing what the true “beginner-level” features are.

That is, we’re either so enamored at what we’re working with, that we’re eager to show what we’re able to do or we skip to more complicated things without explaining the foundation off of which said things have been built.

Maybe I’m off base, but one of the places I’ve seen this crop up in a few conversations is around the idea of Git branching and merging.

That is to say, I’ve had others ask specifically about understanding what a branch is and what a merge does.

For those who have worked with other source control systems, these terms are taken for granted, but for those who are just getting their feet wet and who are hopping into development (even if it’s with Subversion and its branches directory), these are concepts that seem to be glossed over in an attempt to get to more of the “exciting” parts of source control.

At least, as exciting as it can really get.

Continue reading

How To Set Cookies in WordPress

Given the state of many modern web applications, one of the things that I think surprises many developers when coming to WordPress is that the application is stateless.

That is, it doesn’t maintain any type of session using the conventional PHP $_SESSION utilities. If you’re building a web application on top of WordPress where users will be required to login, you may want to introduce something like this.

Dark Side of the Cookie

At the very least, you may be interested in using cookies to manage certain settings for users who have signed in on the front-end using some type of custom functionality you’ve built.

To that end, here’s how to set cookies in WordPress.

Continue reading

Using WP_Query and Multiple Meta Keys

When it comes to searching the WordPress database, there’s probably no better API than WP_Query. That doesn’t mean it’s not without it’s limitations, though (only which will be improved over time, I’m sure).

For example, consider the case where you have two types of meta data that are completely unrelated and you need to run a search for both of them. Essentially, you have WP_Query and multiple meta keys that you need in order to search for information from this database.

In this specific case, I’m not talking about a single piece of meta data that has multiple keys and that would support and AND or and OR clause.

Instead, I’m talking about the idea of having multiple meta keys each of which are associated with a given post, but must all be searched in order to find the posts that have the data associated with it.

In more technical terms, I’m looking for the intersection of post IDs all of which share a common set of multiple, unrelated meta keys.

Continue reading

I’m Watching Your Highlight Reel (There’s No Win in Comparison)

There’s a lot of opinions on the various forms of social media that we have. I’m sure we all have ’em – I know I do – and though I pick and choose those networks that I want to be a part of, I think there’s something that we can find in common with each of them:

They all let us know how well other people are doing and we’re implicitly comparing and contrasting ourselves against those people’s accomplishments even when we know that we’re doing it.

Another way of putting it (and I can’t give attribution because I don’t know who said the original quote) is this:

The reason we struggle with insecurity is because we compare our behind-the-scenes with everyone else’s highlight reel.

Now, I don’t know if, in development, we struggle with insecurity per se, but perhaps we struggle with some type of lack of ability or this notion that we’re falling behind or that we are behind (and maybe all that is is insecurity).

Similarly, we also hear a lot of people talking about imposter syndrome and the effects that this takes on not only their work lives, but their daily lives, as well.

But I’ve also heard another quote that I really like and that I think is relevant, as well:

There’s no win in comparison.

I’m not really into armchair diagnosis so I don’t know what you’d call whatever it is that we each experience, but I’ve been on the Internet the know the following:

  • There are always people who are smarter than you
  • You always have the ability to help someone else
  • Other people will always try to bring you down
  • You have the ability to always try to praise someone for the work that they’re doing

I know, I know. This sounds like some type of greeting card or some type of stationary that you’d ship to someone whenever they’re feeling down – that’s not my intent, though.

Rather, it’s just to say that whenever it comes to that feeling (whatever that feeling is), I know it. And many others do, too.

I know that feel. We all do.

I KNOW THAT FEEL. WE ALL DO.

Here’s the funny thing: It’s one thing to be able to sit back and look at the things that we’re doing that are causing us some type of grief in our lives – and minor grief in comparison to what many go through on a day-to-day basis – and complain about it, but it’s a whole other thing to actually do something about it.

If there’s someone who’s no longer inspiring you, but who is irritating you, then stop following them.

For one reason or another, this is something that takes far more willpower than than it would suggest. Case in point: Think about your Facebook feed, Twitter timeline, your RSS feed, or your buddy list on AOL (if you even still have that ;), and then think about the number of things you read from people who irritate you.

Why do we bother putting up with that?

Clearly, I love the Internet and many things – though not all – that come with it. I love that I’m able to make a living off of it, and that I’ve met incredibly, incredibly talented people with whom I get to interact with each day.

But that level of satisfaction with the Internet comes at the expense at pruning those who do more harm than good to what I want to pay attention to whenever I’m working at my desk for several hours on end.

So unfriend, unfollow, block, step out of the chat room, or just take a short break from whatever it is that may be causing you irritation over satisfaction.

It’s much better and I know I’d much rather be hanging out with other people who are happier, anyway.

Check To See if a WordPress Post Has a Term

In yesterday’s post, I shared how to determine if a given term has a child term. The idea behind doing this is to check to see if a given WordPress term has a child and if the child is actively applied to the post (or post type) in question.

But there’s a caveat that I didn’t mention:

Just because a term has a child doesn’t mean the term itself is actually active.

This means that you could technically be getting a false positive if you’re using the previous method as your sole means to determine if a term has a child. Instead, you need to do one more thing: Check to see if the post has the term applied to it.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑