Software Engineering in WordPress, PHP, and Backend Development

Category: Notes (Page 28 of 49)

Notes on programming-related problems that I’ve encountered while working on various projects.

Organize WordPress Terms in Alphabetical Order

I’d argue that, at this point in time, working with WordPress taxonomies has never been easier.

Sure, creating, tagging or categorized, and adding custom taxonomies to posts and custom post types has always been relatively easy, but when it comes to implementing a solution that utilizes custom post types and/or custom taxonomies, then constructing queries can sometimes be a bit of a pain.

But now, we have more API functions and features than ever before:

Of course, there are still cases in which retrieving and organizing data still leaves something to be desired. 

I don’t fault WordPress for this, though. It’s more of a function of how data is ordered within databases, applications, and in computers in general.

Continue reading

Programmatically Set a Default Menu in WordPress

When it comes to building a theme (or any WordPress project that’s going to feature custom menus), there are several options from which we can choose on how to set a default menu.

We can…

  • use whatever WordPress provides,
  • remove the default custom menu,
  • or programmatically set a default menu

The first two are relatively easy to do (as is the third), but I’ve found that in the majority of my work, clients usually want to have a default menu of options relevant to the project at hand if the user doesn’t set one by default.

Continue reading

How To Check if a Page Is in an iFrame

iframes aren’t exactly the most widely used browser technology anymore, but that doesn’t meant that they don’t have their place, especially in WordPress development.

For those of you who have worked with features such as the Theme Customizer, then you are certainly familiar with how the feature is structured and the role that an iframe plays in giving you the controls and preview of the theme as you’re making changes.

Although it may not be terribly common, there are times in which you may need to check if a page is in an iframe.

There are a variety of reasons in which this may need to be done (dynamically adjusting the height or width of an element on resize, for example), and it’s really easy to do with a little bit of JavaScript.

Continue reading

Filtering wp_title and Why This Matters

For anyone who has experience in building WordPress themes – or even just one theme – or anyone who has experience in working with child themes, or simply modifying a core theme, then you’re more than likely with <a title="wp_title" href="http://codex.wordpress.org/Function_Reference/wp_title" target="_blank">wp_title</a>.

It’s one of the tags in WordPress that’s easy to usd and that’s easy to understand. Straight from the Codex:

Displays or returns the title of the page. A separator string can be defined, and …, that separator can be designated to print before or after the title of the page.

This tag can be used anywhere within a template as long as it’s outside The Loop on the main page, though is typically used in the <title> element for the head of a page.

Not much to it, right?

But it’s also one of the tags that can be abused which can cause problems especially as it relates to plugins.

Continue reading

Adding Post Pagination Attributes in WordPress

Be sure to checkout this comment to see why adding title attributes may not be a good idea.

When it comes to working with pagination in WordPress, it’s relatively easy to manage:

  • There is pagination for index and archive pages.
  • There is pagination at the single post level.

Each of which usually consists of doing the following:

Enough enough, right?

But there are times in which you may want to add or enhance some of the attributes that are on each of these anchors.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑