Software Engineering in WordPress, PHP, and Backend Development

Tag: WordPress (Page 152 of 219)

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

Programmatically Add Post Terms in WordPress

Importing CSV files (or something similar) is something that’s nothing new to web development.

If you’re writing a server-side code that’s responsible for importing a file in the context of WordPress, then you can be doing anything from programmatically creating posts to creating more complex relationships among post types, taxonomies, and so on.

In this case, it’s nice to have an abstract function that can help to do a lot of the repetitive work for you. After all, aren’t functions specifically for that?

Continue reading

Removing HTML Comments in WordPress

Some time ago, I began removing the HTML comment label from beneath the standard WordPress comment form (no, not the Jetpack-enabled form – the one that ships with a default WordPress theme).

Most of you are familiar with the form as it generally looks something like this:

HTML in Comments

HTML in Comments

Generally speaking I find that that block that usually sits between the textarea and the submit input to introduce complexity and likely cause more confusion than anything else.

Continue reading

Adding Plugin Config Files to WordPress

Almost everyone who has worked with WordPress has dealt with wp-config.php. I know – there are a lot of managed hosts out there that take care of a lot of this for you – but even though a person may not have directly edited the file, they have definitely interacted with it.

For those who are unfamiliar:

This file is located in the root of your WordPress file directory and contains your website’s base configuration details, such as database connection information.

Anyway, for sometime now, I’ve been working on a relatively large plugin for a client and have recently taken to introducing a similar type of configuration files. So this raised that question, do what you think of plugin config files?

Continue reading

Tips for Saving and Retrieving Post Meta Data

One of the common things that I’ve seen – and personally done – is mismanaging $_POST data as it comes into the server-side from a form or some type of input element from the front-end. This may be in the case of sending data via Ajax or by doing a standard page refresh.

Chill Out, Veruca. We're getting there.

Chill Out, Veruca. We’re getting there.

Whatever the case, whenever you’re dealing with $_POST data in WordPress and you’re looking to save information into the database, there may be times where you’re interested in saving empty values, and there maybe times where you’re interested in savings values only if they are not empty.

If you’re going after the latter, there are a couple of safe guards you should introduce in your code to make sure that rows are only being written when there’s data to actually be written.

Continue reading

Custom Meta Box Tabs in WordPress

One of the things that has become relatively common within themes that offer a lot of options is the use of tabbed navigation. That is, options that are related are logically grouped into tabs and then the user can navigate through each tab in order to select the options.

Whether or not this is a good thing for themes is outside the scope of this particular post; however, another place in which tabs may also be used is within the context of custom meta boxes.

That is, a custom meta box sits below the post editor and it offers several options or additions to the post meta data each of which is group together in their own tab.

Though I personally find this a bit more effective than using tabs of pages for screen options, that discussion is outside the scope of this post.

Regardless, there are ways to improve the ways in which custom meta box tabs are created such that they are organized in a more maintainable way, and each tab has its own view, partial, or template so that it’s easier to work with over time.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑