WP-Mix

A fresh mix of code snippets and tutorials

Redirect HTTP to PHP via .htaccess

Here is how to redirect specific URL requests to a PHP script for further processing, etc. Very useful for monitoring HTTP activity, logging errors, and more.

(More) secure PHP includes

Quick tip for securing your PHP includes, place them above your web-accessible root directory.

Tabbed sidebar menu with jQuery

Here’s an clean, simple way to add a tabbed sidebar menu using jQuery. You can see an example in the Introspection WP Theme.

Set attachment as featured image

Here’s how to set the first attachment as the featured image for posts in WordPress. This is useful for User Submitted Posts, which attaches uploaded images to each submitted post.

Add Tweet-this with jQuery

Quick jQuery snippet today for adding a “Tweet this” button for all of your site’s pages. You can see a demo here at WP-Mix (lower-right corner).

Google Translate in 2 Steps

Follow this simple two-step tutorial to enable users to translate your web pages into many different languages. Great way to increase exposure and traffic.

Include external, current version of jQuery

Quick tip for including (linking to) the current version of jQuery from external sources.

Display Twitter count in plain text

Twitter’s constant changes make it necessary to update techniques for otherwise simple tasks such as displaying your Twitter count via PHP.

Redirect HTTP to HTTPS

In addition to www canonicalization, you can also canonicalize the HTTP protocol, redirecting HTTP to HTTPS (or vice versa) using Apache/.htaccess. Below you will find several ways to force SSL/TLS for all URI requests. This is especially useful for sites with existing links pointing to unencrypted http:// URLs. Enforcing use of SSL/HTTPS helps to eliminate […]

.htaccess for Apple Touch Icons

Devices and bots are often searching for different versions of the Apple Touch Icon. Here is a quick slice of .htaccess to redirect all apple-icon requests to apple.png.

Allow access to external IPs during development

When developing sites, an easy way to keep things private is to use .htaccess to restrict access based on IP address.

Disable or customize WP read more link

Quick snippet for customizing or disabling the WordPress “read more” link for the_excerpt().