Software Engineering in WordPress, PHP, and Backend Development

Author: Tom (Page 371 of 427)

My Thoughts on Building Web Applications with WordPress

I’ve talked quite a bit about my thoughts on using WordPress for web application development. Specifically, I’ve shared:

During the State of the Word 2012, Matt discussed the past, present, and future of WordPress which included WordPress being an “app engine” of sorts. Some time ago, I stumbled across an article by Matthew Eppelsheimer in which he discusses his team using WordPress as just that.

Specifically, he says:

The WordPress platform essentially manages content and authentication for us, gives us frameworks to build custom UI and our own functionality, and offers extra features in the form of plugins developed by a large community. It gives us everything we need to rapidly build our own custom tools that fit our own process, style, and needs.

Interesting, isn’t it?

Obviously, I’ve been a fan of treating WordPress as such for some time, but I’ve never really shared how I’ve viewed various features and parts of the API for actually building applications.

Since I’ve recently wrapped up a project where we did just this, and since I’m currently in the middle of building one that’s following suit, I thought I’d share a few notes on my approach for building web applications with WordPress.

Continue reading

Quick Tip: Disable Comments Programmatically

If you're an experienced WordPress Developer, then skip down to the code.

I’ve been working on small site that’s serving as a digital storefront for a company. The requirements have called for the homepage to feature a variety of featured projects, a news feed, and similar features all of which are obviously custom queries.

There’s a unique feature to this particular project around the newsfeed that’s a bit atypical for other blogs. That is, the project calls for comments and pings to be disabled.

If you find yourself in a similar situation, here’s a quick tip for how you can disable comments programmatically and how you can disable pings programmatically.

Continue reading

A WordPress Database Index Reference

When it comes to building web applications, all of the major components can be reduced to the following pieces:

  • Frontend
  • Middleware
  • Database

Yes, there are a lot of moving pieces in each of these layers, and there are even layers within layers, but this is generally the architecture that you’re going to find 99% of the time.

And WordPress is no different.

One of the most important aspects of working with web applications that’s often over looked by both beginner and advanced developers alike is the significance of indexes on the underlying database (and I’m certainly not exempt from this).

For any middleware that provides an API for retrieving data from the database, the API is translating the server-side code into database queries. Assuming that the database schema is properly organized, and assuming that you’re leveraging the API properly, you should see very little performance issues.

But if you treat the database as a black box and rely solely on the API, you could be inadvertently affecting the performance of your theme, plugin, or application by constructing poor queries.

I typically keep a short reference of the WordPress Database Index and thought I’d share it here just as much for myself as for you guys.

Continue reading

Using WP_User_Query To Retrieve Users Across Multiple Roles

I’ve covered WP_User_Query in a previous post. In short, WP_User_Query is the preferred method for retrieving user information from the database when working with custom queries.

One of the shortcomings of this API method is that it doesn’t allow you to query across multiple roles. So, for example, if you want to retrieve users that meet a certain criteria but may span across multiple roles – say editors and administrators – the API doesn’t support it.

That said, there is a simple strategy that can be used with WP_User_Query to retrieve users across multiple roles.

Continue reading

Properly Calculating Page Offset in Custom WordPress Queries

Whenever it comes to writing custom queries in WordPress, pagination always seems to give developers problems (myself included!).

I think this can be chalked up to the next / previous pagination links (so does next mean older, or newer?), paginating single posts as well as archive posts, and then occasionally having to write custom queries that include pagination.

One of the areas that I see most confusing – again for myself as well – is properly calculating page offsets especially when working with the WP_Query offset parameter.

The thing is, I think it can be much more simplified (or, perhaps, demystified?) when visualizing the data that you’re working with, and knowing how to use some of the existing API links.

So here’s what you need to know in order to get pagination working when working with the WP_Query offset, page, and number parameters.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑