Custom Archive Templates: A Short Guide Consider this a crash course in creating custom archive templates and all of the functionality that surrounds them.

Whenever you’re working with archive templates in WordPress, posts are typically listed by date in descending order. That is, the most recent posts are listed at the top, and then it goes from there.

Lately, I’ve been working on a few projects that integrate with third-party APIs. These APIs return dates – sometimes two dates, a start date, and an end date – for a given event and customers want to use that information to list posts rather than the date of the post. That is, they want custom archive templates.

It’s not too hard to do this, but before doing so, I think it’s important to give some background information on how the project is built so there’s a bit more context around why, say, a custom query is needed and why you may or may not need to look into pre_get_posts.

I’ll start with a TL;DR first, though. That way, you can get the idea before reading the whole thing.

Continue readingCustom Archive Templates: A Short Guide Consider this a crash course in creating custom archive templates and all of the functionality that surrounds them.

WordPress Widgets: Refactoring, Part 3 Arguably, the biggest problem with the Boilerplate is that everything is encapsulated within a single class. So let's change that with abstract classes.

In terms of updating the WordPress Widget Boilerplate (all of which is tracked in the develop branch), we’ve come a long way in terms of refactoring how it’s organized.

WordPress Widget Boilerplate: The Develop Branch

Thus far, we’ve:

Now we’re ready to start refactoring this code in a much more object-oriented manner.

So if you’ve yet to catch up with the previous posts (any of them, really), I recommend doing so because it’s going to take a little while to bring this up to date. There’s a lot of code to write an explain.

Let’s get started.

Continue readingWordPress Widgets: Refactoring, Part 3 Arguably, the biggest problem with the Boilerplate is that everything is encapsulated within a single class. So let’s change that with abstract classes.

Subtitle Migration: From a Theme to a Plugin Subtitle Migration migrates old theme subtitles to compatibility with the Subtitles plugin.

Recently, some theme shops have been acquired by larger hosting companies. Thus, getting a copy of a theme that you want is now more difficult unless you use said host.

For those who typically read this site via RSS (or some other means), then it’s worth noting that I’ve changed this site back to a stock theme (Twentyseventeen, actually).

Subtitles Migration: A Change to Twentyseventeen

The short reason being that this is a theme that is likely to be long supported since it’s built by the WordPress.org team and it’s going to play well with all of the new and upstream features.

But when changing themes, I lost one of my favorite features: Subtitles. That is, each post that I wrote had its subtitle to help explain and give context to what the rest of the article was about.

I’ve been familiar with Philip Arthur Moore’s Subtitles plugin for some time.

Subtitle Migration: Moving to Subtitles

And the way the previous theme was built along with the way this plugin is built made it possible for me to write a small plugin to migrate all of the previous theme subtitles to the plugin subtitles.

Here’s how where it is, how to use it, and how it works.

Continue readingSubtitle Migration: From a Theme to a Plugin Subtitle Migration migrates old theme subtitles to compatibility with the Subtitles plugin.

WordPress Pagination: A Simple Utility (And Why) Whenever you're building a web application for someone, there are bound to be nuances in which native WordPress functionality may not work.

When building templates for WordPress, you generally have pagination functions that come from the application itself.

WordPress Pagination: Get Next Post

These incude things like:

And there are a few other posts that give you greater granularity around taxonomies such as get_adjacent_post().

I recommend reading all of the above links because they are useful if you’re building a theme, working with custom post types, or are simply looking for a deeper understanding of some of the common template tags.

If, however, you’re looking for an easy way to write your WordPress pagination utility (which I’ll explain the rationale for momentarily), then the rest of this post will cover exactly that.

Continue readingWordPress Pagination: A Simple Utility (And Why) Whenever you’re building a web application for someone, there are bound to be nuances in which native WordPress functionality may not work.

WordPress eCommerce, Past, and Future Customize your site, manage shipping and payments, and list your products on Amazon, eBay, and Facebook with the #1 ecommerce platform.

Rewind a few years, and early e-commerce in WordPress was a bit of a hack (as it was in most blogging software).

There was a time when “WordPress is just for blogging” was a valid argument. Products were simply blog posts. Programmatic gymnastics took place to work around this, but in the end, everything was saved in the database as a post with attributes just like any other blog post.

Then, in WordPress 3.0, Custom Post Types came to be, and this opened a vast array of possibilities. Suddenly everything fit in the posts table. Anything you could think of, from social network content to e-commerce products, could all fit in the posts table, with the postmeta table to back it up.

A post could now be thought of as an entity or a model with attributes or properties described by information in the post metadata table.

But it’s not like that anymore.

Continue readingWordPress eCommerce, Past, and Future Customize your site, manage shipping and payments, and list your products on Amazon, eBay, and Facebook with the #1 ecommerce platform.