WP-Mix

A fresh mix of code snippets and tutorials

Popular Posts

All posts ordered by popularity

Page 2 of 30

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.

Replace all instances of a string in WordPress

Here is how to replace all instances of a string in WordPress.

Create .htaccess files on OS X and Windows

This is a quick tutorial on how to create .htaccess files on Windows (PC) and OS X (Mac). This post also explains a bit about how .htaccess files work, and how to view them on various operating systems.

WordPress: check if user is logged in

Here are some notes and examples of how to check if a user is logged in to WordPress.

Stop form spam with a hidden field

Sick of teh spamz? Here’s an easy way to block a lot of automated spam from your contact form.

CSS transition effect for links

CSS transitions can add a nice effect to links. Here are some quick example snippets for your copy/paste enjoyment.

.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.

PHP Compress CSS & JavaScript

Quick snippets for compressing CSS and JavaScript with PHP’s ob_gzhandler, which will gzip or deflate content depending on browser support.

Infinite loop trap for spammers

In this WP-Mix post, we’ll see how to send spammers on a virtual infinite loop chasing down randomly generated email addresses. It’s very satisfying.

View all WP Post variables

Quick tip to view all WP Post variables, which can be useful for development and debugging in WordPress.

Require user login for any plugin

Here’s a quick trick to require user-login for any plugin. For example, if you want users to be able to use your chat plugin only if they are logged in. Here’s how..

Disable caching with HTML

If you can’t use .htaccess to disable caching at the server-level, here is an alternate HTML-only method that disables Cache-Control, Pragma, and Expires headers via <meta /> tags.