WP-Mix

A fresh mix of code snippets and tutorials

Popular Posts

All posts ordered by popularity

Page 13 of 36

Proper usage of get_search_query()

This tutorial explains the two ways to properly use WordPress’ template tag, get_search_query(), depending on context. Note that the information provided in this post also applies to the similar tag, the_search_query().

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.

.htaccess block spammer

Quick tutorial showing how to block a specific spammer via .htaccess. This technique is perfect for forum and site owners who want to block access to pesky visitors based on their reported IP address.

Canonical snippets for WordPress

.htaccess enables us to easily clean up 404 errors and other misdirected HTTP traffic for better SEO. Here are some canonical snippets for WordPress and beyond.

WordPress add titles to post navigation links

In this post, we add title attributes to WordPress post-navigation links, for both previous/next archive navigation and previous/next single-post navigation. These are some simple copy/paste functions that you can add directly to your theme (or via plugin).

Download large files via SSH

Here is one way to download huge files (or any size file) from your server to your local machine. All you need is an SSH connection and the scp command.

Add Facebook OG Attributes to HTML Tag

When adding Facebook Open Graph (OG) tags to your web pages, it is a good idea to add the required attributes to the <html></html> tag. Here is one way of doing it.

Canonical URLs for a single page site

In this tutorial, I share a handful of .htaccess techniques for implementing canonical URLs for single-page websites. Also referred to as “brochure” sites (among other things). These are all plug-&-play code snippets, just add to any .htaccess-capable site and enjoy the SEO benefits of having canonical URLs. I use these snippets on my sites, such […]

Limit HTTP Request Size

This .htaccess snippet can be used to restrict the total size of the HTTP request body sent from the client.

CSS text-shadow snippets

Here are some of my favorite/most-used CSS text-shadow snippets.

Whitelist POST access with .htaccess

Here is how to whitelist POST requests for a specific file. For example, you can protect chat, forum, and other heavily targeted scripts from malicious acitivity.

WordPress wp-config.php tricks

A concise collection of wp-config.php tricks from my WordPress sites to yours.