Software Engineering in WordPress, PHP, and Backend Development

Tag: WordPress (Page 140 of 219)

Articles, tips, and resources for WordPress-based development.

Using WP_Query To Search For a Person

One of the most powerful features of WP_Query is that it allows for us to create a type of mini-search engine within the context of our WordPress projects.

No, this isn’t as sophisticated as something or someone who’s actually in the search business, but you can create some pretty elaborate queries using WP_Query.

Conversely, you can also create some pretty simple queries that do a good job of returning a subset of data. For example, say you’re interesting in using WP_Query to search for a person. There may be a little bit of criteria that the user has to provide, but doing something like this is usually really easy.

Continue reading

Maintainability of WordPress Theme Customizer Code

When working with the WordPress Theme Customizer, one of the things you may find yourself doing is writing out inline styles into one of the templates for your theme. Most likely, this will happen within the context of your header template since that’s where most of your styles and JavaScript sources are included.

Sure, it’s possible to handle a lot of the work via JavaScript and to use separate stylesheets to handle the general styles, but if you’re looking to set something up like, say, backgrounds that can be selected via the Theme Customizer, then you’re going to need to write out inline styles.

And if you’re in the habit of keeping your code separated such as styles reside in CSS files, behavior functionality resides in JavaScript files, and templates hold markup and PHP, then this can be a little bit annoying. It breaks the trend, you know?

There is somewhat of a solution to this, though.

Continue reading

The Shelf Life and Feature Creep of a WordPress Theme

With Mayer about to turn a year old (they grow up so fast), with a healthy backlog of features sitting in the queue, and with two other themes sitting in the planning stage for the first part of this year, I’ve been thinking a bit about WordPress themes as a whole.

Sounds like I have too much free time doesn’t it?

But seriously, one of the things that I do wonder about is how long a WordPress theme can actually be sold and continue to be viable for users especially since design trends change. Additionally, I think that there are times in which a theme has reached the maximum number of features it can justifiably offer before it just begins to feel a bit crowded.

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

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑