Posts

WordPress: Add custom text to posts matching a tag

The example below shows how to add text to the bottom of posts, based on specific conditions. To get the right value for “custom_text”, you likely just want to add a paragraph tag, but you can copy existing HTML from your site to get a good example. add_filter(’the_content’, ‘custom_category_text’);   function custom_category_text($content){ global $post; $custom_text […]

Optimizing WordPress Tag Pages

Normally I don’t like to write about “blogging,” but since website traffic generates some interesting data, it’s worth looking at it from a computer science perspective, to see the issues involved. By default, WordPress has two multi-valued fields associated with an article, “Categories” and “Tags.” Categories are treated as a closed, hierarchical set, and tags […]

Proxying HTTP requests with PHP

The following code will proxy requests to an external API. This has several advantages: Control over an API key Set caching headers to prevent overuse of an API Prevent issues with cross-domain scripting errors Limit the scope of what APIs can be called through your proxy $query = urlencode($_GET[’query’]); $url = ”;   $url = […]

, , ,

Identifying important keywords using Lunr.js and the Blekko API

Lunr.js is a simple full-text engine in Javascript. Full text search ranks documents returned from a query by how closely they resemble the query, based on word frequency and grammatical considerations – frequently occurring words have minimal effect, whereas if a rare word occurs in a document several times, it boosts the ranking significantly. This […]

Diagnosing Disk I/O issues in a VPS

Every so often, my Linode goes into a state of apparent frantic I/O. Page loads slow down a bit, and I get regular email alerts indicating a potential problem: Subject: Linode Alert – disk io rate Your Linode, linode90147, has exceeded the notification threshold (800) for disk io rate by averaging 2146.05 for the last […]