WP-Mix

A fresh mix of code snippets and tutorials

Popular Posts

All posts ordered by popularity

Page 2 of 32

Replace all instances of a string in WordPress

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

View all WP query variables

Micro Tip for the day: slice of PHP code for viewing all WordPress query variables. Very useful for figuring out custom loops and such.

Difference between home_url & site_url

Here are some notes to help discern the subtle (and oft-confusing) differences between the WordPress functions, home_url and site_url (and their related “get” functions, get_home_url and get_site_url). We’ll look at the output of these functions and how they relate to the WordPress General Settings.

Detect Chrome, IE, Firefox, Opera, and Safari

How to detect each of the major browsers (Chrome, IE, Firefox, Opera, Safari) client-side via JavaScript.

Display category name in WordPress

Here are two snippets for displaying the category name and displaying the category link in WordPress.

Break Out of Frames for WordPress

Quick JavaScript snippet to prevent scrapers and turds from framing, defaming, and/or stealing your precious content..

jQuery Scroll to Target with Offset

This tutorial shows how to create “scroll-to” links with jQuery. For example, if you want to add a link on your page that smoothly scrolls the user to a specific location, add the following code snippet to your JavaScript file.

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.

WordPress Cron Not Working

Some servers disable the functionality that enables WordPress Cron to work properly. This post provides an easy fix that should work on any server.

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.

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

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.