WP-Mix

A fresh mix of code snippets and tutorials

Popular Posts

All posts ordered by popularity

Page 8 of 35

Display Images with User Submitted Posts

Here is a quick recipe for displaying linked images for images submitted with the User Submitted Posts plugin.

WordPress repair and optimize InnoDB

This tutorial explains how to use WordPress’ built-in tools for optimizing database tables that are of the InnoDB type. Also works for good ’ol MyISAM database tables.

WordPress clean up do_pings

When your WordPress site is configured to enable pings, the database can fill up with many do_pings WP Cron entries. This post provides a couple of quick ways to clean them up, by either disabling the functionality or deleting the do_pings entries from the database.

Get Current Post Type in the WordPress Admin Area

In WordPress, you can create posts, pages, or any custom post type. Within your theme template, you can get the current post type using the core WP function, get_post_type(). But that doesn’t work in the Admin Area. For example, my Disable Gutenberg plugin provides conditional functionality to the “Add New” and “Edit” screens based on […]

Force file download with .htaccess

Here is a quick .htaccess snippet that will force files to download instead of displaying in the browser. This method works for any site running on an Apache server.

PHP: Get $_SERVER Variables

I use a variation of this function to get super global $_SERVER variables in my free shapeSpace WordPress theme. The function returns all relevant variables contained in the $_SERVER array. Note this is a general PHP technique, so WordPress is not required for this one.

Auto-Focus Form Fields with jQuery

When you load a page that contains a form, it may be useful to automatically place the user’s cursor in the first form field. This post explains how to do autofocus with jQuery.

WP Admin link to All Options

The WordPress database houses more settings than those available in the Admin Area. Here’s a quick code snippet to display an “All Options” screen to view otherwise hidden data.

WordPress enqueue user-agent stylesheets

WordPress makes it clean and easy to enqueue custom stylesheets via the functions.php file. Here’s how to do it for user-agent stylesheets.

WordPress redirect logged in users

Nice WordPress snippet to redirect logged in users to any location. Also optionally redirect visitors who are not logged in to WordPress.

Simple PHP login form

Here’s a quick PHP snippet for creating a simple login form for your site.

WordPress Disable jQuery Migrate

The jQuery Migrate plugin is used to help sites upgrade to the latest version of jQuery. The script restores APIs that have been removed, and the development version shows warnings in the browser console for any deprecated or missing APIs. This enables developers and admins to more easily upgrade from older to newer versions of […]