Category: WordPress
-
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…
-

San Francisco and Napa Valley
I was recently fortunate enough to spend some time at Carneros Resort in Napa, California with the WordPress.com VIP team. We did a bit of coding, a bit of lecturing, and a bunch of networking. It was an amazing experience and I can’t wait to attend the event in the future.
-
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 –…
-

Cambridge, MIT, and WordCamp Boston 2013
I had the pleasure of attending WordCamp Boston 2013 last weekend where I got my third WordCamp T-Shirt for 2013. The camp was held at the Microsoft New England Research & Development (NERD) Center. I also had the pleasure of checking out the MIT campus while I was in Cambridge which was a total treat.…
-
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…
-
Some Helpful Varnish Commands
Look at incoming requests for URL varnishlog -c -m RxURL:”/somepage.html” Look at requests made to the backend for URL varnishlog -b -m TxURL:”/somepage.html” Requests for one specific host varnishlog -c -m RxHeader:”Host: somehost.com” See cache age for a specific host varnishlog -c -m RxHeader:”Host: somehost.com” | grep Age Test VCL compilation varnishd -C -f /path/to/file.vcl…
-

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…
