WP-Mix

A fresh mix of code snippets and tutorials

Popular Posts

All posts ordered by popularity

Page 3 of 36

WordPress Shortcode Display Search Form

Here is an easy custom WordPress function to display your theme’s search form via shortcode. This makes it easy to display the search form on any Post or Page.

Fade in page content with jQuery

Here are two simple techniques to fade in page content with jQuery. The fade-in effect isn’t for everyone, but it’s a nice tool to have in the box.

JavaScript redirect to URL on select

JavaScript and jQuery techniques for redirecting to the specified URL when the user makes a selection.

View all WP Post variables

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

Include files from parent directory, subdirectory

This post concludes our trilogy of posts on getting file and directory path information with PHP and WordPress. In this final path-related post, you’ll get numerous ways to get and include files from parent directories, subdirectories, adjacent directories, and even the same directory, just to round things out.

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.

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

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.

PHP Spoofing Headers with cURL

While working on a recent book-sale script, I needed a way to test various request headers. This script is what I used to spoof just about everything except the IP address (which it seems is not possible to spoof via PHP/cURL).

WordPress Get Category ID from Slug

Quick WordPress snippet for getting the category ID from the category slug.

PHP Check if Request is HTTPS

Here we have a simple and effective PHP function that checks whether or not HTTPS (via SSL) is used for the current request.

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.