WP-Mix

A fresh mix of code snippets and tutorials

WordPress link attachment to parent post

This tutorial provides four techniques for linking WordPress attachment pages back to their parent posts. Adding such a link makes it easy for users to view an image or other attachment, and then quickly navigate back to the original gallery in the parent post.

CSS Vertical Center Block

Here are two ways to vertically center a block-level element using CSS. The first method uses CSS flexbox, while the second method uses CSS transform.

WordPress readme.txt tricks

The readme.txt file plays a central role when developing WordPress plugins, especially when hosting them at the WordPress.org Plugin Directory. In this post I share some esoteric readme.txt tricks that plugin and theme developers may find useful. You also may want to read about how to add your plugin to the WP Plugin Repository (i.e., […]

Get WP, PHP, and SQL Info

Here are some sweet code snippets for getting various types of server information. Includes more functions for getting and/or checking various types of WordPress, PHP, and SQL data. Strictly plug-&-play for quick reference and copy/paste usage.

WordPress Functions for Theme Testing

Some quick copy/paste snippets taken from my dev/test theme, Introspection. Posting them here for reference so I can grab ’em as needed.

Simple Ajax Chat: Auto-Clear Chats

This tutorial explains how to hook up automatic clearing of chat messages with my WordPress plugin, Simple Ajax Chat. Note that this tutorial is for the free version of SAC.

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.

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.

jQuery Auto Resize Multiple Textareas

The User Notes Widget that’s included in my Dashboard Widgets Suite plugin enables users to edit notes right on the WP Dashboard. To make things extra awesome, each note automatically expands as the user types more lines of text. This post explains how I achieved this trick, aka multiple auto-resize textareas.

Replace contenteditable with textarea

Working on my WordPress plugin, Dashboard Widgets Suite, I needed a solid way of replacing contenteditable with a textarea on form submit. Here is a simple solution along with some bonus notes on dealing with certain HTML tags.

WordPress Basic Allowed HTML for wp_kses

Here is a function that I use in my plugin, Dashboard Widgets Suite. It provides a sane, practical set of HTML tags and attributes for WP’s wp_kses family of functions.

jQuery check inline CSS property

Working on my WordPress plugin, Dashboard Widgets Suite, I needed a quick function to check a property defined via the inline style attribute on a specific element. Here is an easy, plug-n-play solution that works great.