Software Engineering in WordPress, PHP, and Backend Development

Tag: WordPress (Page 174 of 219)

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

An Easy Way To Check if a Post is Paginated

Out of the box, WordPress supports the ability to paginate individual posts.

For those who aren’t familiar, it means that you’re able to literally paginate your posts such that a post may consist of multiple pages (kind of a weird concept, huh?).

Paginated Posts

Some people may use this feature, some people may not; however, if you’re working on a theme, then you need to be prepared for this case and provide appropriate styling.

But the way if which you determine if a post is paginated or not can lead to a bit of cluttered code, so in order to keep the code as readable as possible (and to keep the logic separated from the template), here’s one way that you can check is a post is paginated.

Continue reading

On Using Helper Files in WordPress

One of the things that I appreciate about certain application development frameworks is their approach to convention over configuration.

By that, I mean that they tend to take the approach of “a place for everything, and everything in its place” rather than setting a ton of variables in a set of different files to tell the core system where everything is located.

In my opinion, WordPress is a little bit of hybrid of this kind of stuff, but I tend to look at it in the direction of modifying configuration files.

After all, we have both `wp-config.php` and we have `functions.php`. Both of these serve their purpose, but `functions.php` can get specifically cluttered as a theme or an application grows.

Continue reading

Contributing To WordPress 3.8 (And Future Releases)

The first time that I talked about contributing to the WordPress codebase was just over a year ago today.

Time flies.

Granted, I’ve made other contributions that have been made to the WordPress project since then – updating Codex articles, working on the JavaScript standards, and so on – but I’ve not actually had a chance to commit code to the project until this release.

And like many of the people who are using WordPress 3.8 for the first time today, I’m more excited about this release than I have been for a long time.

Continue reading

Modular Procedural Programming The WordPress Theme Customizer

One of the things that I love about working with WordPress is the entire hook system – you know, the various `add_action` and `add_filter` calls that you can make in order to manipulate content prior to sending it up to the browser.

I think that it provides a really powerful mechanism for working content prior to saving it to. or retrieving it from, the database.

Now, to be clear, I’m not someone who thinks that everything should be object-oriented versus functional versus procedural. Generally speaking, I think that certain paradigms lend themselves to certain strategies more so than others.

Case in point: The fact that WordPress `functions.php` file is nothing more than a collection of functions is fine with me; however, I really like the fact that I can write plugins using object-oriented programming.

Anyway, one of the the things about the hook system is that it can result in writing repetitive code – which I’ll show in a moment – which can in turn make for very long, very tedious, and very redundant functions.

Or, more generally stated, it can result in less than stellar programming practices.

So when these situations arise, I try to look for opportunities that help to keep functions lean, but yet maintaining a purpose, as well as easy to follow. I think it pays off significantly when it comes time to read back through the code, maintain the code, and to document the code.

Continue reading

How To Add a Class to a Single Post in WordPress

As I’ve continued to work on the theme that I’m planning to use after Standard (and that I’ hoping to begin dogfooding within the next month or so), there have been a couple of features that I’ve wanted to implement for the sake of styling.

For example, there are times where I want to be able to style a single post, and though there are a number of ways one can go about doing this, I like to try to be consistent in how I approach the solutions I implement.

To that end, I’ve wanted to add a custom class name to a single post but only only the single post page.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑