WordPress Hacks

Auto-Update WordPress with XAMPP for OS X

XAMPP is a great application for running your own local development environment. It’s available for Linux, Windows, and Mac OS X. Personally, XAMPP is the only local environment app I use. Out of the box, XAMPP doesn’t allow for automatic updates inside WordPress. Not for plugins, not for themes, not for core. The Problem WordPress…

How to Disable Auto-Saving in WordPress

WordPress offers auto-save functionality making it easy to ensure your work isn’t lost. However, post revisions can add up quickly. Here are some tips to disable the post revisions and auto-save functionality. Disable Auto-saving Add this to your functions.php file: **NOTE** if you disable autosave, it prevents the “preview” function from working as you would…

How to Prevent the WPAutoP Filter in a Shortcode

As I was developing a simple shortcode the other day, I realized the output was being filtered by wpautop(), which adds <p></p> to the return code. I finally found a snippet of code from BetterWP.net which solved exactly my problem. The main issues was that the shortcode was being processed too late in the code,…

How to Get the Thumbnail URL Path

Here is a quick and easy way to extract the URL source for the thumbnail [of the featured img] of your post. Inside the Loop Outside the Loop If you also needed to get the height and width of the thumbnail, you can use the follow lines of code: You can read more on the…

The Ultimate Body Tags

It can be really easy to style your content and site if you have the right body tags setup and know a little bit of CSS. Here is the ultimate set of body tags that will let you easily style everything from the <body> down. Something to note about the page404 class, you need to…

How to Mass Delete Users Based on their Role

@MattBrett tweeted out a couple days ago, asking how to mass delete users specific to what role they were. For example, being able to delete 15,000 users that were all “subscribers” in WordPress. There is not a native way to do this, as this would be a rare edge case that you would either have…

How to Disable WordPress’ AutoP

Have you ever needed to disable the infamous wpautop that WordPress automatically inserts into posts and pages? Here’s a quick snippet of code that lets you easily manage it using custom fields. Add the below code to your functions.php file. function disable_autop() { global $post; $disable_autop_var = get_post_meta($post->ID, ‘disable_autop’, TRUE); if ( !empty( $disable_autop_var )…

Automatically Set the Featured Image in WordPress

Often I find myself forgetting to click on “featured image” when I’m writing a post. But I know I need one because it makes the world go ’round for WP Force. What’s the solution? Automatically set the featured image. Here’s a quick snippet of code you can throw into your functions.php file that will your…