WP-Mix

A fresh mix of code snippets and tutorials

Popular Posts

All posts ordered by popularity

Page 14 of 36

Shorten text with CSS

There are several ways to shorten text, depending on the situation and goals. It’s preferable in most cases to shorten text server-side via PHP, but also possible to shorten via jQuery or even CSS.

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.

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

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.

WordPress wp-config.php tricks

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

Rename uploaded files in WordPress

Here is a function used in my free WordPress plugin User Submitted Posts that enables you to rename WordPress media uploads. So for example, if the user uploads a JPG image named “sweet-ride.jpg”, the following function will append a random string to rename the file “sweet-ride-random.jpg”, where “random” is a random alphanumeric string containing 20 […]

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.

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: Display Site Creation Date

I’m surprised that WordPress doesn’t provide a function for getting the site creation date. Knowing when the site was set up can be useful for all sorts of things. Copyright dates. Bragging rights. Whatever. If you want to display the date your site was first installed, here is one way to do it.

CSS Multiple Media Queries

@media queries are instrumental in creating responsive CSS designs. This tutorial explains how to combine multiple media queries to keep things optimized.

Exclude category in WordPress

Ever wanted to exclude a category in WordPress? Turns out it’s pretty easy to do without having to install another plugin.

CSS Dark Pre Tag Styles

Here is a quick CSS snippet for adding some smooth, dark styles to any <pre> tag. One-step snippet for complete pre styling: add to your stylesheet and done.