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 TwentyContinue reading “I Open Sourced My Twenty Sixteen Child Theme”

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 truncateContinue reading “Truncate a WordPress Database To X-Number of Posts”

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,Continue reading “Automatic Featured Images for YouTube Posts”

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 statsContinue reading “Add a pageview column with Jetpack data source”

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. [code language=”php”] <?php $link_queue = array(); $exception_queue = array(); $timestamp = date( ‘Y-m-d H:i:s’ ); $rss = simplexml_load_file( $argv[1] ); foreachContinue reading “A little PHP script to watch for 404 errors”

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. [code language=”php”] $posts = new WP_Query( array( ‘posts_per_page’ => -1, ‘post_type’ =>Continue reading “Assign Random Featured Images To All Posts”

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: [code language=”sql”]DELETE FROM wp_comments WHERE comment_type=’trackback’; DELETE FROM wp_comments WHERE comment_type=’pingback’;[/code] Great, but now your comments counts are all out of whack, since that integer is stored inContinue reading “WordPress Trackback Maintenance”

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. [code language=”php”] <?php class rdc_search_object { function __construct() { add_filter( ‘posts_search’, ‘filter__posts_search’ ); } function filter__posts_search( $query ) { $query_parts =Continue reading “WordPress search__only_ Variables”