Experimenting with magic return methods on WordPress filters

I was catching up on some of the specifics of the new default theme that shipped with WordPress 4.7, Twenty Seventeen. When I saw this: We’ve all seen it a thousand times. There’s a filter that just needs a basic value, but since add_filter requires a callback function, we have to go out of our way to define […]

Get an attachment ID by URL in WordPress

We all know you can use wp_get_attachment_url() to return an attachment’s URL by passing in the ID, but what about the reverse scenario? There are a lot of long-winded examples of how to get an attachment ID by URL floating around the interwebs. Most of them limit results to only returning images or use expensive […]

Remove specific menu items from the WordPress Admin

Sometimes it’s best – especially when you’re using WordPress as a CMS – to remove those unwanted admin menus that create clutter for clients. They are never going to use them so why confuse their admin experience? For example: if the client isn’t going to blog, why include Posts or Comments in the menu at […]

How to hide your WordPress version number…completely

Did you know that your WordPress version number is visible to everyone? As Matt Mullenweg rightly pointed out several years ago, simply hiding your WordPress version number is not enough by itself to stay protected from potential threats (you should always be keeping your WordPress installation up-to-date). But perhaps you have a client who has […]

Add first and last classes to your loop without using JavaScript

So you’re a pixel-perfect designer who wants to keep control over your WordPress loop styles? Hell yeah! You’re already pretty cool in my book. You’ve probably got a fancy post separator, or a brilliant doodle to fit between your last post and the comments. Whatever the reason, you don’t have CSS class selectors for targeting […]

The simplest way to require/include wp-load.php

If you want to use WordPress functionality in a PHP file that exists outside of your WordPress installation then you need to include wp-load.php. Perhaps you could call this “hooking into WordPress”. Maybe you’re already using some sort of relative path method, like: But this can create problems if directories change. You need a clean, […]

Create a shortcode for displaying Order History on your Cart66 site

I’m a fan of Cart66. It’s easy to integrate and has a fair amount of features that make it a flexible e-commerce and member management solution for WordPress. However, there’s one pretty big feature that Cart66 is missing: the ability to display the Order History of a logged in user. What? Really? Yes. Really. This […]