Software Engineering in WordPress, PHP, and Backend Development

Tag: WordPress (Page 209 of 219)

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

How To Find a User By Meta Data in WordPress

Thanks to Curtis for giving a heads up to WP_User_Query - it's a nicer alternative to the original post.

One of my favorite things about the WordPress API is the ability to store custom meta data with objects such as pages and users. I’ve been working on an application where this scenario has presented itself:

  • The end user is able to create a company
  • Each company can have an administrator based on users in the system

To do this, I’m creating a relationship between the company and user by associating the company’s ID as part of the user’s meta data.

Later in the application, I need to retrieve each administrator for each company which has required the use of a helper function to get a user by meta data.

The details of how I’m doing this are aren’t exactly interesting for this post, but I figured that this was a common enough issue and easy enough to generalize that I’d share how to programmatically get a user by meta data in WordPress:

Continue reading

Writing WordPress Code – Clean, But Not Clever

I think of one the biggest challenges that programmers face as we become more comfortable and well-versed in our programming language(s) of choice, is that we become intimately aware of some of the more clever things we can do with the code.

For example, one feature of dynamic programming languages is that they offer anonymous functions. They’re really powerful and you can do some really cool stuff with them, especially in JavaScript; however, this always introduces a tension:

Are we writing code to be clever or are we writing code for others to understand?

Since I spend the majority of my time working with and writing about WordPress, I thought I’d share my thoughts on writing WordPress code.

Continue reading

What’s The Best Way To Manage WordPress Assets?

When it comes to developing web sites and web applications, there are two things that developers always consider as it relates to the project’s assets and its performance:

  • The number of HTTP requests a page requires
  • Loading all of the assets versus only what we need for a page (also known as YAGNI or You ain’t gonna need it.)

This is an obvious problem as we have tools like Head.js and Sprockets for managing this issue, and then we have customizers for larger utilities like Bootstrap that allow us to customize our builds.

Managing WordPress assets is becoming incredibly more relevant especially as frameworks, themes, and plugins become more powerful, and as people begin to build full applications on top of WordPress.

Continue reading

Extending WordPress Plugins with Hooks

I've closed comments on this post as I'd like to keep the discussion on the source post.

Earlier this week, I shared my thoughts on custom, non-standard hooks within the context of WordPress themes which resulted in a great discussion in the comments and on Twitter, so it seems only appropriate to share a resource on how to get started with WordPress plugin hooks.

WordPress Plugin Hooks

Last week, Pippin Williamson of Pippin’s Plugins published a terrific article on Envato that explains how to write extensible plugins with WordPress plugin hooks.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑