Category: WordPress Code
-
I’m on WordPress.TV
My talk from WordCamp Kathmandu entitled “Coding With Jetpack” is now available on WordPress.TV. I hope you enjoy π [videopress xQwbucAg]
-
I Open Sourced My Twenty Sixteen Child Theme
Today, I open sourced my Twenty Sixteen child theme. It includes an empty resume page template and a clean travel shortcode that uses Google Maps. You’ll need to check out the source code for usage, but it’s very simple π This child theme is meant to be only very small improvements to the WordPress Twenty…
-
Truncate a WordPress Database To X-Number of Posts
I regularly work with huge MySQL database files (10G-100G) so making copies and importing them locally for use in VVV is extremely cumbersome (at best). Here are some MySQL statements that allow you to truncate all but the most recent 1000 posts in your WordPress database. These are useful because they allow you to truncate…
-
Automatic Featured Images for YouTube Posts
A few people have asked how I get the WordPress featured image for my YouTube posts. It’s actually quite simple – YouTube provides a thumbnail for each video you publish (in the form of http://img.youtube.com/vi/{video_id}/0.jpg) that is free for the taking. Here is a little script that detects a YouTube embed and automatically downloads, imports,…
-
Add a pageview column with Jetpack data source
I decided to get with the times and give Jetpack a try. If you’re unfamiliar with Jetpack, it’s essentially a WordPress plugin which ties your self-hosted WordPress blog to WordPress.com’s servers and allows nifty features like an image CDN, Gravatar hovercards, centralized comments, and a multitude of other features. Personally, I love the WordPress.com stats…
-
Graphite Graphs for WordPress
It’s no secret that I love Graphite. My co-workers think it’s a bit ridiculous how much data I feed into our graphite server. I may be a bit excessive, but I have a monitor in my office which allows me to see at a glance every little detail about our network in real time –…
-
A little PHP script to watch for 404 errors
This is a quick script which reads a standard RSS feed and then grabs the response header for each feed item and makes a log file of 404 errors. Useful in debugging sticky situations. Throw it in cron like this: */30 * * * * php /path/to/script.php http://somesite.com/feed/ >> /path/to/log 2>&1 Or run it on…
-

Assign Random Featured Images To All Posts
Could be used for setting up dummy content for a staging environment, or something similar. Be my guest and let me know how you decide to use it in the comments! Also, check my github for this function built into a WP-CLI command.
-
WordPress Trackback Maintenance
Sometimes you just need to get rid of all that trackback data from your WordPress database. Here’s how to do it manually from your MySQL command line: Great, but now your comments counts are all out of whack, since that integer is stored in the wp_posts table. Here’s how to check that: And here’s how…
-

WordPress search__only_ Variables
Here’s another object-oriented mu-plugin that you can expand upon if needed. This adds the option to perform a search with “&search__only_titles” or “&search__only_content” in the url to search only titles or content of posts. Go ahead and use this juicy tidbit and let me know in the comments what creative use you found for it.
