Category: WordPress Code
-

Never-Ending Pagination in WordPress
Take your site’s slideshows to the next level with the following: The next part actually filters the wp_link_pages arguments and decides where to put a next button where one didn’t previously exist. I also threw in an additional previous button, which uses some javascript to take the user back to the previous page. There’s probably…
-
WP-Config Options You Probably Didn’t Know About
1. Override options “siteurl” and “home” 2. Revisions 3. AutoSave Interval 4. New wp-content location 5. Manage cookie options 6. Debug options 7. Memory Limit 8. Cache 9. Custom wp_users and wp_user_meta tables 10. Override default file permission 11. FTP and SFTP Constants 12. Proxy access
-
Delete All Tags With 0 Posts
Delete all tags with zero posts tagged. Can also be used to delete all tags with one post. Or other amounts … Use at your own risk. From the MySQL command line. Make sure to BACK UP YOUR DATABASE first. On the last line, you could also do c.count < 3 which would remove all…
-

SQL_CALC_FOUND_ROWS and no_found_rows
By default, the WordPress SQL query that selects posts from the database will use “SELECT SQL_CALC_FOUND_ROWS …”. This is mainly for pagination purposes, to speed up subsequent queries for the next set of results. Writing the query that way certainly helps speed up the site as a whole, but is useless in some circumstances. Remedy:…
-

WordPress Hardening 101
With the recent public exploit of W3 Total Cache and the release of WordPress 3.5, it’s high time to tighten up security across the board on your WordPress blog. Here are a few things you can do to clean things up. File Permissions Perhaps one of the most important things you can do is clean…
-

Merry Christmas, Now Patch Your WordPress Sites!
Thanks to the release of http://seclists.org/fulldisclosure/2012/Dec/242 on Christmas Eve, I’ve spent my holiday working security for several sites. This exploit allows an attacker to take advantage of the “open” nature of W3 Total Cache’s cache files to extract password hashes from the database cache. I agree with Jason on this – why did the author of…
-

Rewrite WP Attachment Images on the Fly
At first, this may not seem to have any real-world use, but consider this: You need to set up an independent development environment for your site, and you’d rather not copy gigabytes of files from your production server’s wp-content directory. Without the following function, keeping everything synced could turn into another full-time job, especially if…
-

Purge All WordPress Users of a Particular Role
I needed to delete all of the subscriber level users on one of my sites recently, and couldn’t find an easy way to do it. My solution? Write some code. It was definitely quicker and easier to run this snippet than to manually delete over 7,700 users from my database. Drop this code into an…
