Software Engineering in WordPress, PHP, and Backend Development

Tag: WordPress (Page 163 of 219)

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

WordPress Meta Boxes: Aiming for Simplicity

This is the first post in a series on how to achieve simplicity with WordPress meta boxes.

For anyone who has does any kind of work with WordPress meta boxes, you know that it generally consists of the following steps:

  1. Define the meta box
  2. Define the callback functions responsible for displaying the markup

Pretty simple, isn’t it?

Of course if you’re looking to introduce a more advanced functionality into your meta box then you’re likely going to want to introduce stylesheets, JavaScript dependencies, nonce values, and perhaps even tabs to logically separate the options.

Given the fact that I’ve recently looked at some of the various ways to save data in WordPress meta boxes, I thought it might be work sharing one way to help separate the business logic from the presentation logic as it relates to incorporating WordPress meta boxes either in themes or plugins.

Continue reading

Two Ways to Save Meta Box Data in WordPress

Recently, I was having a conversation with a friend about some of the various ways to serialize the values that are present within a collection of meta boxes that are defined for any type of post – be it a post, page, or a custom post type – within WordPress.

For example, imagine that you have a custom post type that has, say, four different meta boxes that are available below the main content area.

These meta boxes can be laid out in one of two ways:

  • The meta boxes can be listed individually with each meta box having its own set of values. Think of WordPress’ Excerpt field, Discussion field, and and Sharing Field.
  • The meta boxes can all be contained within a single container accessible by individual tabs.

The question is does the way that the meta boxes are displayed influence how the values are serialized in the database?

Continue reading

Adding Tabbed Navigation in WordPress for Custom Menus

One of the nicest features of the latter versions of WordPress includes the custom menu system. Although people can always introduce too many areas in which custom menus can be introduced, the core feature and customization options make it possible to do some really cool stuff with custom menus.

Case in point: With many of the popular front end frameworks that are now available, such as Foundation and Bootstrap, it’s really easy to add tabbed navigation in WordPress in templates, widgets, and so on.

Though there are a number ways of to do this, one flexible way that I’ve used multiple times requires two things:

  1. A function for retrieving the post IDs for the post types contained in a custom menu
  2. An instance of `WP_Query`

At that point, all you need is the name of the menu for which you want to retrieve the post IDs.

Continue reading

Adding Multiple Sections on WordPress Options Pages

One of the most confusing aspects of working with WordPress is the Settings API.

In an attempt to make a little bit easier to understand, I’ve written a series that takes a long look at the API as well as an example project that’s available for download for others to study (and to contribute to in order to improve).

But, as with most things in programming, there are still things that can crop up now and again that can leave you scratching your head. Case in point: Let’s say that you want to introduce two sections (or three or four, even) to a single options page.

Unless you do this correctly, you’re likely to notice that the ‘Save Changes’ button will only save the changes to the last group of options. Luckily, there’s an easy way to keep your options logically grouped while also maintaing serialization through a single ‘Save Changes’ button.

Continue reading

Isolating Styles When Creating a Theme-Specific Plugin

This is probably the most unique way that I’ve started a post since I’ve been writing here, but given the fact that my family continues to grow every couple of years or so, I figure that it stands to reason that the forthcoming example would be inevitable.

This past weekend, I was doing the usual routine of unboxing, ahem, diapers, refilling the wipe container and so on.

I told you this was going to start off weird.

I told you this was going to start off weird.

There’s nothing spectacular or unique about what you see above, except for the fact that Huggies makes both the container and the wipes that fit within the container.

But here’s the neat thing: when you purchase the wipes made by the vendor of the container, they provide a separator to let you know exactly how many to get out to fill the container.

The divider separates how many wipes fit in the container.

The divider separates how many wipes fit in the container.

I hesitate to say that this is kind of “neat” because, y’know, we’re talking about diapers. Additionally, we can technically buy any wipes and/or any container just so long as the wipes stay fresh, right?

But when you purchase both of the products from the same vendor, then there’s this small bonus that you get in terms of grabbing the exact amount of wipes you need for the container.  Obviously, the two were made for one another.

So, naturally, I made the leap into thinking about WordPress themes, WordPress plugins, and theme-specific plugins.

It’s what anyone would logically do, right?

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑