Software Developer. Computer Geek. INTJ.

Tag WordPress

The WordPress Template Hierarchy

Visual guide to the WordPress template hierarchy.

WordPress Themes by Anders Norén

I really like Baskerville (which I'm currently using for this blog) and Lingonberry.

WordPress Plugins

These are WordPress plugins I use and recommend…

CryptoPHP backdoor in pirated CMS themes & plugins

A backdoor that has been dubbed “CryptoPHP” was found hidden in pirated (“nulled”) themes and plugins for WordPress, Drupal and Joomla.

Display a list of a user’s Gists in WordPress

This code creates a shortcode, [gists], which displays a list of all Gists by a user, grouped into categories then listed alphabetically.

Replace URLs in the WordPress database when moving between servers

Run this to replace URLs in the database when moving a WordPress blog from one URL to another.

Script to download MySQL database & files from live to development server

This is a script I use on a lot of sites to copy the database (MySQL) and any uploaded files to the development site, and modify the database as required.

Split WordPress theme functions.php into multiple files and autoload them

I use this to split my theme’s functions.php into multiple smaller files on particularly complex sites, and to autoload those files (instead of having to manually require each one).

Using Gravity Forms with WP-Types custom date fields

This is a filter to take Gravity Forms format dates (dd/mm/yyyy) and convert them to WP-Types format dates (integer).

Sort and filter WordPress posts query by a custom field

In this example the event start & end dates are entered as timestamps using WP-Types. It could also be modified for Advanced Custom Fields which uses strings.

Keyboard shortcuts to indent/outdent and format as code in WordPress TinyMCE

This allows you to indent lists/paragraphs in the TinyMCE WYSIWYG editor using Tab, and outdent using Shift+Tab. I wrote it because I write a lot of nested lists, it’s tedious using the keyboard to indent and outdent, and I couldn’t find any…

Insert a post into WordPress from an external script

With wp_insert_post() and wp_set_post_terms()…

Display WordPress admin area dates in UK English (en_GB) format (day-month-year)

While entering several back-dated posts into a WordPress blog, I got annoyed at the date fields being in American month-day-year format and decided to fix it.

Store WordPress post password cookies for the browser session only (instead of 10 days)

WordPress saves post password cookies for 10 days, and there is no setting or filter to change that, but you can use this code to replace the form action entirely.

Hide the permalink and Edit button on the WordPress Edit Post admin page

This hides the permalink and edit button on the Edit Post page in WordPress. It is useful for when permalinks are not editable (e.g. if it uses the post ID only) in that case its really just taking up screen…

Hide the title box on the Edit Post page in the WordPress admin

This hides the title textbox in the Edit Post page in WordPress. It is possibly useful when using a theme like P2 that doesn’t actually display the title, so you don’t want to be going to the trouble of writing one.

Set WordPress site URL in the config file instead of the database

WordPress stores the site URL in the database by default (which I have never understood), and its a pain to have to type out the UPDATE SQL or search in phpMyAdmin to change it. This is a simple way to…

Automatically enable plugins in new WordPress Multisite blogs

There are three options (that I know of) for automatically enabling a plugin in new sites.

Automatically generate subdomain for new WordPress Multisite blogs

When you create a new WordPress Multisite blog from the admin area, you have to enter three things: Site address (subdomain or folder name), Site title and Admin email…

Set site/plugin options for all blogs in a WordPress Multisite network

I used this code snippet as part of a WordPress Multisite plugin, to allow me to quickly set some options for all blogs in the network.

List of all blogs in a WordPress Multisite network

This code was used to generate a menu showing all blogs on a WordPress Multisite installation.

Alternative to the_category() in WordPress that works correctly with nested categories

The WordPress function the_category() doesnt work particularly well when you have hierarchical categories.

Set default category / tags for a new WordPress post using links

I used this code to automatically set the default post title, category and tags for a new WordPress post based on which link was clicked.

Force additional categories to be added to a WordPress post on save

On one WordPress blog I have categories for “Starred” and “Archived”, in addition to the real categories. I hacked this together to make sure the posts would still go into Uncategorised as well.

Toggle category with ajax in WordPress theme (frontend)

This is a follow-up to Toggle “Starred” Category in WordPress – making it more generic and usable for multiple categories.

Set default theme for new WordPress Multisite blogs

Even if you disable all but one theme, WordPress seems to default to TwentyTen when creating a new Multisite blog. The fix is simple though – add this to wp-config.php.

Prevent WordPress sending any emails

I did this simple hack on a private WordPress Multisite blog, to stop it sending me emails every time I created a new blog. It’s definitely overkill to stop all emails, but unfortunately I couldn’t find any hooks that let…

Bug fix for Filosofo Comments Preview WordPress plugin – increment the number of comments when previewing

Filosofo Comments Preview is a WordPress plugin that lets you preview comments on your blog before you submit them. In the current version (1.5) it doesnt increment the number of posts, so it still says there are no comments when you…

Display all posts from one category in a sidebar widget in WordPress

This is a modification to the theme’s functions.php that adds a widget to list all of the posts in the “Starred” category.

Redirect to post/page after publishing in WordPress

This redirects to the post/page itself after publishing or updating a post in WordPress.

Toggle “Starred” Category in WordPress theme (frontend)

How to add a simple “star” flag to posts (a la Gmail).

© 2021 Dave James Miller — Powered by WordPress

Theme by Anders NorenUp ↑