Software Engineering in Web Development, Backend Services, and More

Tag: WordPress (Page 175 of 220)

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

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

Add a Custom Wrapper To The WordPress More Tag

Most of the popular CSS frameworks that are available today offer some sort of grid system for us to use such that we can arrange our content in rows and columns. This is advantageous for a number of reasons, the least of which is not for aiding responsive design.

When it comes to WordPress, one of the most common elements that authors will use is the `more` tag.

Just as there are times where we may want to indicate that a class has (or doesn’t have) a `more` tag, we may also want to wrap the tag in a row with columns on either side of the tag.

This gives us flexibility in styling the tag not only by helping to place the text by using columns and/or offsets, but also by taking advantage of a grid in the context of responsive design.

Continue reading

Add a Post Class in WordPress: The More Tag

WordPress’ `post_class` function makes it really easy to write out a variety of class names to post containers that give us a finer-level of control when working on styling WordPress posts.

But there are times in which you may want to actually add a custom class to a post (or to a single post) depending on the nature of the content of the most.

And sure, you can easily add additional parameters to the `post_class` function, but those are still static parameters that will be applied to every posts.

What about in cases where you want to add a class if, say, no more tag is present in the content?

Continue reading

Am I Using Sass in WordPress? Yes and No.

After talking about my post-Standard plans yesterday, I received several questions – some on Twitter, some via email – about my use of LESS rather than Sass since Sass is going into WordPress core.

It’s a good question, to be sure, and it’s one I’ve thought about since this ticket in Trac. Since I’ve been using LESS for over a year in various projects, I’ve had to decide how I want to move forward with development of those projects and future projects, as well.

Continue reading

« Older posts Newer posts »

© 2026 Tom McFarlin

Theme by Anders NorenUp ↑