Digging into WordPress v3.3 Update

New version of Digging into WordPress now available! The DiW v3.3 update covers WordPress 3.3 & 3.2, with fresh new sections and updated content throughout the book. Similar to the latest versions of WordPress, DiW 3.3 refreshes the look and feel of the book, with updated graphics and screenshots, streamlined content, and new bonus versions [...]

Notification List for v3.3 Printed Books

Digging into WordPress v3.3 is now available, and more printed books are on the way. It can take some time for the books to be printed and delivered, so we’re setting up a notification list for people who want to know when the new books are back in stock. To get on the list, just [...]

WordPress CMS Plugins

To make room for new content for the DiW 3.3 update, we’re “excerpting” this section into its own blog post. Here you’ll find an extensive round-up of CMS plugins for WordPress. Includes CMS plugins for better admin functionality, user-role management, custom content display, e-commerce & shopping carts, forums, newsletters, and more. Administration Tools These plugins [...]

Smarter Slugs ~!@$%^&*()={}<>[]?

See those crazy characters in the title of this post? Now see how they don’t appear in the post’s URL? That’s one of the finer details of the WordPress 3.3 update: smarter permalink slugs. So when you type something like you see in the title of this post, with all the funky characters, or even [...]

Plugins for SOPA/PIPA Blackout

Get involved! Here is a list of stop-SOPA/PIPA plugins to help blackout your WordPress-powered site: SOPA Blackout Plugin “This plugin allows you to set SOPA blackout dates for your WordPress website, as well as a variety of options on who the anti-SOPA is shown too. You can have it shown instead of your site for [...]

Goodbye Admin Bar, Hello Toolbar

When the Admin Bar hit the streets in WordPress 3.1, people seemed to either love it or hate it. And rightly so, it was a significant change in the appearance of the WP Admin area, and if not disabled in your User Profile, the front-end of your site as well. Many tips, tricks and plugins [...]

Poll Results, Book News, and More!

We’ve had several polls going in the DigWP.com sidebar for quite some time now, and it’s been interesting watching the trends change over time. The first and longest ongoing poll is HTML or XHTML for Markup?, which now has over 7,000 votes. HTML or XHTML for Markup? When the poll started in April 2010, the [...]

Displaying Theme Data with WordPress

A cool trick you can do with WordPress is display information directly from your theme’s style.css stylesheet. I recently used this on a site where the theme’s version number is used throughout the template to keep things current and consistent. get_theme_data() The function that makes it possible is called get_theme_data(), and it simply returns an [...]

HTML Formatting for Custom Menus

For some projects, it’s nice to output clean, well-formatted markup. Using theme template files enables great control over most of your (X)HTML formatting, but not so much for automated functionality involving stuff like widgets and custom menus. One of my current projects requires clean, semantic HTML markup for all web pages, but also takes advantage [...]

Clean Up “Cannot redeclare” Hack

One of my clients was hacked with the so-called “Cannot redeclare” hack. It seems closely related to the nefarious TimThumb hack, so if you’ve been hit by either of these hacks, you should check for the other. Apparently these hacks affect shared servers, so if you host multiple WordPress sites, chances are high that they’re [...]

That’s Not Spam: False Positives and Ham

Everyone loves a good comment. Readers benefit from the shared information and authors appreciate the conversation and feedback. But you gotta keep the spam out. Akismet and other anti-spam plugins do an excellent job of automating the process, but it’s a good idea to watch out for false positives: legitimate comments marked as spam. Rescuing [...]

Import Feed, Display in Multiple Columns

Recently I worked on a project where a single RSS feed was imported and displayed in multiple columns on the web page. Certain pages display feed items in two columns, others in groups of three or more. This technique uses WordPress’ built-in fetch_feed functionality to parse external feeds, and a slice of PHP magic to [...]

Where to Get Help with WordPress

We get quite a few requests for 1-to-1 WordPress support, but unfortunately don’t have the resources to help everyone directly. We frequently see emails like this: I understand that you are not able to give 1:1 support, so I would like to ask: where (web, forum, IRC) do I get answers about this? So people [...]

3 Ways to Reset the WordPress Loop

WordPress does an excellent job of keeping track of what’s happening with the loop, but once you start customizing parameters and setting up multiple loops, it’s a good idea to explicitly reset them using one of three WordPress template tags. In this DiW post, we’ll explore these techniques to get a better understanding of when [...]

Using ‘$’ instead of ‘jQuery’ in WordPress

Writing out ‘jQuery’ a billion times in a script makes it harder to read and bloats its size. Let’s stop doing that and start writing ‘$’ like you see in the vast majority of jQuery code in the world.

Create an Articles-Only Feed

WordPress makes it easy to publish content in any number of categories, with any number of tags, and with any type of custom post format. So for example, in addition to full articles, you could also offer screencasts, links, side posts, tweets, and all sorts of other peripheral content. Complementary material may work great for [...]

How to Redirect Logged-In Users

WordPress provides a variety of ways to redirect logged-in users. In this DiW post, we explain each of these methods along with some useful tips and tricks along the way. These techniques enable you to redirect logged-in users to internal pages, external pages, and even return them to the current page. wp_redirect The wp_redirect function [...]

New DiW Affiliate Program

Earlier this year, we had to close down our original affiliate program due to fraud and abuse. We hated to do it, and have been trying since that time to find a more secure way to make it happen. Thanks to all of the great tips, ideas, and feedback we received from our original affiliates, [...]

Clean Up Weird Characters in Database

It’s been a crazy month, with lots of drama all over the place. Here at DigWP.com, we had an episode where the site was all screwed up and not loading or only partially loading, blank white pages, and the whole bit. During the process of keeping it together and trying to restore full functionality, numerous [...]

Super Summer Sale!

The summer months are upon us, and to celebrate we’re having a Super Summer Sale for huge savings on both the PDF version and Print Editions of Digging into WordPress. For the next 7 days, you can save $15 on the Printed books and $7 on the PDF/eBook. Just apply the following codes during checkout [...]

So really, don’t use just /%postname%/ as your permalink structure.

Update: This issue is FIXED in WordPress 3.3. Here’s the really short version: I used /%postname%/ as my permalink structure on CSS-Tricks for a long time. I have lots of Pages. My site went down. I changed my permalink structure to begin with a number. Now it’s fine. And the long version: All the sudden [...]

Fun Edit Posts Link (✍)

Tiny little fun idea by Dave Rupert. Put this: <?php edit_post_link(‘✍’,”,’ ‘); ?> before all your: <?php the_title() ?> So like: <h1><?php edit_post_link(‘✍’,”,’ ‘); ?> <?php the_title() ?></h1> And when logged in, if you have edit privileges for that post/page/whatever, you’ll see the titles like: ✍ How To Be Awesome Where the little icon is [...]

Secure uploads, upgrade and other directories with .htaccess

It sucks, but a lot of plugins require certain directories to be set at CHMOD 777 for its file permissions. Of course, you should not use any plugin that requires 777 directories, but if you absolutely must, you can help protect the folder by adding a thin slice of htaccess. This works great for any [...]

Leave the Visual Editor ON

Just a quick reminder to anyone out there that may not know.. Enabling the Visual Editor in your User Profile settings gets you access to both Visual and HTML editors in the Write/Edit Post screen. Just click on either tab above the toolbar to toggle between modes. So you can write your posts in HTML [...]

Poll: Best Caching Plugin for WordPress?

New Poll! We’ve got several polls running in the sidebar at DigWP.com, and the latest asks which caching plugin is best. Sure it’s all anecdotal and subjective, but user feedback is a fun way to see trends and get an idea of the top plugins. Amazingly enough, there currently are over 1,000 plugins tagged as [...]

New Printed Books are Here!

We’ve got a fresh batch of Digging into WordPress 3.1 now available in printed format. Each book is printed in full-color, with new extra-thick covers and slick spiral binding for laying it flat while reading. These features make the print edition feel really solid and durable, like you know you’re reading a well-crafted, quality book. [...]

4 Ways to Loop with WordPress

At the heart of the WordPress theme template is the venerable WordPress loop. When you’re looking at your index.php file, for example, the loop is the part that typically begins with if(have_posts()) and contains all the tags and markup used to generate the page. The default loop works perfectly well for most single-loop themes, but [...]

Graphing Blog Comments Over Time

One of my other blocks, CSS-Tricks, has been around a number of years now. There are nearly 1,400 unique pages of content almost all of which have a comment thread. I had a feeling that in the last four years, despite fairly steady growth in traffic and subscribers, that the number of comments per post [...]

Admin Bar Tricks

According to our latest poll, so far the votes are pretty much split on whether people love, hate, or don’t care about WordPress’ new Admin Bar. Over time, it looks like “Hate it” has started to pull ahead, but it doesn’t matter because the Admin Bar is here to stay, regardless of opinion. Already there [...]

15 Anti-Spam Plugins for WordPress

During the recent book update, we needed to make some room for the new WordPress-3.1 content. The book is already over 400 pages and growing. So we have to make some hard decisions about which content is useful but maybe not needed in the book. And, as useful as long lists of anti-spam plugins might [...]

Deluxe Widescreen Edition

We cooked up a special widescreen edition of the PDF for Digging into WordPress 3.1. This new edition contains exactly the same content as the original, but instead breaking the spreads into single-page format, the widescreen version retains the same “two-up” layout, so it’s just like you’re reading the actual printed book. Here are a [...]

Pre-Orders for 3.1 Printed Books

Good news! Digging into WordPress version 3.1 is now at the printers, with a fresh batch of books expected within the next 4-5 weeks. The new 3.1 books should be available for purchase in May, and we’ve opened up pre-orders for those wanting to use the PDF and other goodies while waiting for the printed [...]

What to do when Auto-Update Fails

Ahh yeah, WordPress just rolled out another update to version 3.1.1. If you’re able to upgrade via the Admin, updating your site(s) should be a piece of cake: just log in, click a few buttons, wait a few minutes, and done. The convenience of automatically updating the WordPress core, plugins, and themes is awesome, but [...]

Tumblr Links with Post Formats

With WordPress 3.1’s new Post Format functionality, it’s easier than ever to create your own Tumblr-style Link posts. We do this right here at DigWP.com using our own hand-rolled method. Scroll through a page or two of the site’s most recent posts, and you’ll see that Link posts are formatted and styled differently than regular [...]

Poll: Love or Hate the WordPress Admin Bar

WordPress 3.1 includes the new Admin Bar. It’s enabled by default for all users, and provides quick links to key Admin pages. There’s been some strong opinions on both sides, so let’s put it to a vote:

Digging into WordPress 3.1 Update

Digging into WordPress is now updated for WordPress 3.1. This is the book’s 8th major update, with new material for WordPress 3.1 and extensive revisions throughout. Without a doubt, Digging into WordPress is more focused and current than ever before. Version 3.1 – Better than Ever Lots of new stuff for DiWP 3.1: Complete guide [...]

6 .htaccess Tricks for Better WordPress SEO & Security

Here are six htacccess tricks that will help improve the security and SEO quality of your WordPress-powered site. We do this using .htaccess to establish canonical URLs for key peripheral files, such as your robots.txt, favicon.ico, and sitemap.xml files. Canonicalization keeps legitimate bots on track, eliminates malicious behavior, and ensures a better user-experience for everyone. [...]

What We Learned Publishing Digging Into WordPress

Digging into WordPress is an entirely self-published book. It’s not that way because we just arbitrarily decided that self publishing was hip and that was what we were going to do. In fact, the plan early on was the opposite. Step one, we thought, was to write the book. So we did that. Then step [...]

DiW Version 3 Sold Out

Just a quick post to let everyone know that printed copies of Digging into WordPress version 3 is now sold out. The plan is to update the book for WordPress 3.1 and then print up another batch. Thank you to everyone who bought a printed copy of v3!

New DiW Theme: Quantify

Quantify is a clean, well-styled WordPress theme focused on usability and readability. Quantify is the base theme used for my new design, built with HTML5, liberal doses of CSS3, and a few jQuery snippets thrown in for good measure. Here is the demo, and here is a quick run-down of the features: Features Built with [...]

Hosting Client Sites on a WordPress Network

Regular updates keep WordPress secure and expand the feature set, ensuring the platform meets both the developer’s and their client’s needs. The flipside of regular updates is the maintenance of WordPress installs. Once you start maintaining more than a few installs for your clients, keeping both plugins and WordPress up to date can become a [...]

Ajax Requested Page Return Only Content

I posted a little tip on CSS-Tricks the other day about how you can load only parts of other pages on a site via Ajax, and how to do that without needing additional HTML wrapping elements to keep it clean. A common criticism of this is that the Ajax request still loads the entire page, [...]

List of WordPress Developers & Designers

Looking for WordPress developers and designers? So are many people. Time is scarce these days, and we get quite a few folks asking about where to go for help with their WordPress site. Most of the WP peeps that we know are just as busy as we are, so it would be helpful to have [...]

Should Clients Update Their Own Sites?

A common question for WordPress designers/developers is how to handle plugin upgrades and upgrades of WordPress itself. I recently logged into a client site for maintenance to find that someone had “attempted” an upgrade of WordPress, but that it had failed: An automated WordPress update has failed to complete – please attempt the update again [...]

New htaccess Code for WordPress Permalinks

While manually upgrading a bunch of old WordPress sites, I realized that the WordPress htaccess rules for permalinks had changed. For many years and versions, the htaccess code that enables WordPress permalinks went unchanged, resulting in an almost sacred set of htaccess directives. Here are the original permalink rules as currently provided at the WordPress [...]

Simpler Login URL

The default URL for logging into your WordPress powered site is: http://yoursite.com/wp-login.php. Or if you’ve installed in a subdirectory, something like http://yoursite.com/wordpress/wp-login.php. I’ve wished that was a little cleaner, especially when you are doing something explaining to a client where to log in over the phone. Fortunately changing this can be very easy. To make [...]

Custom Login/Register/Password Code

In this DiW post, we transform three slices of code into a clean & stylish tabbed menu that visitors can use to login, register, and recover passwords from anywhere in your site. Too many features & details to explain up front, so check out the working demo to see the finished product. On the menu: [...]

Custom Message After the Comments

Have you ever wanted to close a comment thread, but leave a note to communicate why the thread is closed? Many blogs will just update the content of the blog post to say that comments are closed and why. That’s better than nothing, but that puts the message in a bit of an awkward place. [...]

Make the Visual Editor Actually WYSIWYG

In otherwords, match what you see when creating/editing a Post or Page in the WordPress visual editor to what you get when you actually publish it. It’s easier than you might think! Basically you can declare a special CSS file that the visual editor will use to render itself while you are editing it. If [...]

DiW Book Giveaway and Holiday Sale!

Three big things for all the folks out there who are thinking about buying our book Digging Into WordPress for themselves or as a gift for someone this year.

1. A Giveaway!
2. Special Holiday Discounts
3. A Scratch & Dent Sale

ALL AJAX Theme Update

One of the themes that is an exclusive download to all you good-looking people that purchased The Book is the ALL AJAX theme. The idea behind it is that the page never* reloads. Whenever an “internal” link is clicked, the main content area replaces itself with content that is fetched via Ajax. It always worked, [...]

New Updates/Downloads System

We’ve set up a new system for downloading DiW updates. It’s designed to make the upgrade process easier for everyone. Here’s how it works: Go to http://digwp.com/wp-login.php Use your purchase email address to reset your password After logging in with your new password, you’ll be redirected to the downloads page Download your update! Once you [...]

Putting FTP Info in wp-config.php to Ease Updates

Are you hosting your WordPress sites on one of those hosts where WordPress asks you to provide FTP details before upgrading itself or upgrading plugins? So when you click to do an upgrade, instead of just launching into it, you get a screen like this instead: I don’t have experience with loads and loads of [...]

Display Total Number of Blogroll Bookmarks

Quick WordPress tip for you today! A reader recently asked about displaying the total number of blogroll bookmarks on their site. This sounds simple enough but not everyone meddles with code these days, so here is a nice PHP snippet that will do the job: <?php $numlinks = $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->links WHERE link_visible = [...]

Dynamic Archives

Have you ever seen WordPress archives where you select something (usually a month/year) from a dropdown and it takes you to a page where you can view that? It’s fairly common. WordPress almost has built in functionality for it, since you can specifically tell the wp_get_archives() function that you want the values to be returned [...]

Change Your Database Prefix to Improve Security

One of the awesome things about WordPress is that it’s a dynamic publishing system that uses a database to store your site’s information: posts, options, plugin and theme settings – all of this data is stored in your site’s database. It’s like the brain of your WordPress installation. Unfortunately the WordPress database is also a [...]

Customize Your WordPress Dashboard

There are many ways to customize the WordPress Dashboard. Over the years, the Dashboard has evolved into a highly flexible information portal, enabling an overall, big-picture view of the main components of your site, while also providing granular data on everything from recent comments and plugin updates to incoming links and WordPress news. And that’s [...]

Using Google Custom Search in WordPress

Once a WordPress powered site starts getting quite a bit of content, the default built-in search becomes fairly useless. It just isn’t very smart. If you wrote a comprehensive article about He-Man, but since have written five other articles that just mentioned He-Man in passing, a search for “He-Man” will turn up your comprehensive article [...]

DiW v3.0 Printed Books!

We’re now accepting orders for printed editions of Digging into WordPress version 3.0. The books are currently finishing up at the printers, and should be ready to ship within the next week or so. Here are a few shots featuring the new black cover and black coil binding: The book looks and feels good – [...]

Speed Up Your Blogging with WordPress Shortcodes

Save time by replacing your most commonly typed words and phrases with WordPress shortcodes. For example, if you are frequently typing your blog’s URL, you could place the following code your theme’s functions.php file: function shortURL() { return ‘http://your-site.com/’; } add_shortcode(‘myurl’, ‘shortURL’); Now whenever you write a post in “HTML-mode”, you can include your blog’s [...]

WordPress 3 Template Hierarchy

This chart is one entire page in our book, but I thought it would be good to focus on specifically. Template hierarchy has gotten a bit more advanced since the last time we covered it. The idea is that WordPress will look for files in a theme to use to render the current page in [...]

WordPress Security Keys

In our recent post on pimping the wp-config.php file, we explain that using strong Security Keys is an important part of securing your WordPress installation. In this post, we want to zoom-in on Security Keys and look at what they are, how they work, and how to use them to greatly improve the security of [...]

Version 3.0 Launch!

It’s here! Digging into WordPress Version 3.0 is here and it’s packed with goodness, including a new chapter on WordPress 3, updated core content, and a super-sleek new cover. Check it out: DiW3 cover by Chris Coyier Updated Core Material Much has changed with WordPress since our previous book update (v2), so for version 3.0 [...]

Pimp your wp-config.php

Easily, the most important file in your WordPress installation is the wp-config.php file. It serves as your site’s base configuration file, controlling key aspects of WordPress’ functionality and enabling WordPress to do mission-critical stuff like connect to the database. Without wp-config.php, WordPress simply won’t work. So whenever you install WordPress, one of the first things [...]

Randomized Grid of Posts

I’m all about tinkering with different ideas to display posts with WordPress. After all, it’s just a bunch of data at our fingertips! WordPress makes it easy to output whatever we need. Not long ago we experimented with making a Thumbnail Based Archives. Now let’s build a Randomized Grid Archives. 1. Create a page template, [...]

Easy Comment Management via SQL

Here are some sweet SQL code snippets for easy comment management. Sometimes it’s easier to modify comment status and delete unwanted comments on a sitewide basis. Using a program like phpMyAdmin makes it so easy to do stuff like remove spam, close/open comments on old posts, enable/disable pingbacks for specific time periods, and so on. [...]

Using Menus in WordPress 3.0

The menu system in WordPress 3.0 was hotly anticipated. But perhaps unbeknownst to many average WordPress users, actually using this feature takes some coding work. In fact, even enabling the features take a bit of code. Below we’ll go through the steps for inserting a custom menu into your theme. Note that many themes will [...]

DiW v3.0 Book News

We have been working diligently on updating Digging into WordPress and finding the best print-on-demand solution. Thanks to your suggestions and ideas for book printing, there were many options to check out. After sizing things up, we’re pleased to announce the following: Digging into WordPress version 3.0 will be released near the end of August [...]

Thumbnail Based Archives

Here at Digging Into WordPress, we’ve attached thumbnail images to every single (non-link-style) post since day one. We started before WordPress 3.0 had the specific feature for thumbnails. We did it just by attaching a file path to the thumbnail image as a custom field. We clearly display each of those thumbnails in the design [...]

Optimizing WordPress Permalinks

Configuring your WordPress permalinks is simple and only takes a second, but understanding what they are and how they work is key to setting up the best permalink structure possible. Your site’s permalinks are like the street address for your site’s web pages. They help both people and robots understand your site’s structure and navigate [...]

Media Temple WordPress Hack

It looks like Media Temple WordPress installs have been hit with a WordPress Redirect Exploit. We got hit here at DigWP.com, but have cleaned things up and are taking steps to prevent it from happening again. Here is what Media Temple knows so far: Visitors viewing posts on your blog may be redirected to a third-party [...]

GPL Showdown

If you missed the Matt Mullenweg vs. Chris Pearson debate live debate today, this is my wrap up: Matt: Thesis is violating the law because it violates GPL. Chris: No it isn’t. Matt: Businesses can thrive under GPL. Chris: So? Matt: Why won’t you bring Thesis over to GPL? Chris: Because I would feel like [...]

WordPress Security Lockdown

This article is split into two parts for ez reference. First some information on the evil WordPress “Pharma Hack”, and then a recipe for protecting your site with a solid security lockdown. Choose your own adventure: Pharma Hacked Security Lockdown Pharmaceutical Apocalypse A few weeks ago, DigWP.com was hit with the so-called Pharma Hack. We [...]

DiW Book Winners!

Congratulations to the following three winners of our July 4th Book Giveaway: Seth John Schibelli Jenny Each winner receives a free copy of Digging into WordPress, including all of the free themes and lifetime updates. We’ll be sending your download links immediately. AND: as the first name picked, Seth also wins the huge stash of [...]

The “Frameworks” Discussion

I’ve never been a big fan of “theme frameworks.” I quite like hacking up WordPress myself and making it do the things I want it to do. I feel like most theme frameworks have a ton of custom functions for you to “help” in doing that kind of stuff. For example, adding a block of [...]

4th of July Book Giveaway!

In celebration of the 4th of July and our one-year anniversary, we are giving away three copies of Digging into WordPress! To enter, just tell us what you would like to see in the upcoming version 3.0 of the book. We are working on the new version right now and will be updating the book [...]

Shortcode for Includes

One thing that WordPress doesn’t have the ability to do “out-of-the-box” is do includes, in the sense of including the content of one post into the content of another post directly in the post editor. For the umpteenth time around here, shortcodes to the rescue! This issue came up while my co-worker Tim at Wufoo [...]

What? No Printed Copies?

What’s up with no more printed copies? We completely sold out of printed books a few weeks ago. We’re currently looking into print-on-demand solutions to make more of the printed copies available to those who want them. The problem is that the book is over 400 pages and full color. And POD is pretty much [...]

Blogging in Markdown

WordPress defaults to a WYSIWYG editor when composing a new Post. Of course WYSIWYG is a bit of a misnomer. What you “get” when you publish that post is dependent on the template and the CSS in place in the theme. In fact, WordPress doesn’t even call it WYSIWYG, they call it the “Visual” editor. [...]

Show Post Thumbnails in Feeds

One of the nice things about using WordPress’ new post-thumbnails feature is that they provide tons of flexibility in terms of where and how you display your post thumbnails. By design, post thumbnails are not included within post content, so they will not be displayed in your blog posts unless you call them specifically with [...]

WordPress JSON API Plugin

WordPress already kind of has an XML API. Basically, RSS feeds. WordPress creates feeds for all kinds of stuff: recent posts, comment threads on any Page or Post that has comments, category-specific, tag-specific, and more. The codex covers all this and we’ve also covered creating your own unique feeds that could literally be from any [...]

WordPress Default CSS Styles

WordPress gives us full control over the presentation of our websites. We specify which classes and attributes to use in our template files, and then apply CSS using our theme’s custom stylesheet. Behind the scenes, WordPress generates its own classes and IDs, and applies them to specific HTML elements in theme files and database content. [...]

Complete Guide to WordPress 3.0 Awesome New Features

One thing that people love about WordPress are all of the awesome new features rolled out with each new version. WordPress has come a long, long way since I first started working with it back in 2005, and the soon-to-be released version 3.0 takes WordPress’ powerful functionality even further. WordPress 3.0 is currently in public [...]

Quick Book Notes

WordPress 3.0 should be out before we know it. We will be updating the book of course, but we aren’t promising any particular timeframe for that. Probably “late summerish”. We just want to make sure we do a good job and revisit the entire book and update what is needed as well as write about [...]

Specify Unique CSS File Per Post

I’m a HUGE fan of being able to link up a CSS file on a per-page basis. I just find it extremely common that a page needs CSS styling unique to it, and I hate litering a sites main stylesheet with customizations that only one particular page needs. We’ve talked about this before, and even [...]

Add Private Content to Posts via Shortcode

Recently, WPRecipes posted an incredibly useful technique that uses a shortcode to add private content to blog posts. This functionality makes it easy to manage leftover data, miscellaneous notes and other communication by keeping everything together with its corresponding post. Consolidating information like this helps to streamline flow and organization into the future. Combine the [...]

Poll: HTML or XHTML for Markup?

HTML5 is rapidly gaining popularity, but how many people are actually using it? If not HTML5, then what? When creating websites, designers have a variety of options for markup: HTML5 (Not quiite official yet) HTML 4.01 (Strict, Transitional, Frameset) XHTML 1.0 (Strict, Transitional, Frameset, & Basic) XHTML 1.1 (+ Basic XHTML 1.1) You can build [...]

Custom Page Titles from Scratch

The titles of pages are controlled by the <title> tag in the <head> section of a website. They are important for all kinds of reasons. Telling the user where they are. The name of the page when bookmarked both locally and socially. They are important for SEO. So how do we typically handle page titles [...]

Next/Previous Post Navigation Outside of the WordPress Loop

WordPress provides several navigational template tags to make it easy for visitors to surf your pages. There are basically two different types of template tags used for chronological post navigation: posts_nav_link() – for navigating various archive (non-single) pages previous_post_link() & next_post_link() – for navigating single-post pages These template tags output the HTML markup required to [...]

Poll Results: How Do You Use the WordPress Media Library?

Back in January, we asked How Do You Use the WordPress Media Library?. After more than 700 votes, the results are in: Overall, looks like happy endings for the WordPress Media Library. As you can see, it appears that a majority of users are quite content with the Media Library and use it frequently. Nearly [...]

eReaders and Digging Into WordPress

When the iPad came out I was able to convince myself that it really is my responsibility as a publisher of a digital book that I should have this device for testing. Ha! Yeah right, I just thought they were cool and wanted one. So the big question is… Can you read Digging Into WordPress [...]

Call a Widget with a Shortcode

We covered how to run a shortcode in a widget. But what about inserting a widget with a shortcode? I recently had this situation come up. I had a single page where I just wanted to be able to chuck in a widget without the whole rigmarole of creating a special widgetized area and probably [...]

WordPress Custom functions.php Template, Part 2

In a recent post, we show you how to clean up and enhance the functionality of WordPress with a custom functions.php template. In that post, we explain how using a custom functions.php template can speed up development while optimizing many key aspects of WordPress. In this post, we deliver another prime collection of 15 custom [...]

wpSEO vs. All-In-One SEO Pack

The most popular SEO plugin for WordPress is certainly the All-In-One SEO Pack. It’s on just about every plugin roundup you’ll ever see. It’s free. It works well. But it’s not the only kid on the block. One of the guys from WP Engineer has a competing product: wpSEO. I’ve now used them both. I [...]

Remove/Replace Content from the WordPress Database

A useful tool to have in in your WordPress toolbelt is the ability to quickly and easily search for, find, and replace specific strings of text directly from the MySQL database. We can do this by entering SQL queries either directly or through one of those handy interface applications like phpMyAdmin, which seems like one [...]

Nice Way to Encourage Plugin Upgrading

A while back we talked about upgrading plugins. Specifically the All-in-One SEO pack and the controversy surrounding how it turns it self off after (some) updates. This is what that plugin looks like when it needs an updating: Normal look for a plugin that needs updating But W3 Total Cache also needed an upgrading, and [...]

WordPress functions.php Template with 15 Essential Custom Functions

When designing WordPress themes, I always add a common set of custom functions to the theme’s functions.php file. This speeds up development time because I don’t have to hunt for and individually copy the same slew of functions for every theme. I just drop in a copy of my functions.php template and build up from [...]

Declare Multiple Widgetized Areas

Have a bunch of different areas you wish to declare as a widgetized area? Save repetative code by creating a quick array of their names, then loop through that array calling the register_sidebar() function on each one. Elementary PHP stuff here, but hey, it just saved me quite a few lines of code in a [...]

6 Ways to Display WordPress Post Content in Multiple Columns

Most blogs display their content in single columns, but it’s also possible to display content in multiple columns. Multiple-column layouts are perfect for newspaper and magazine-style themes. Here are six ways of getting the job done. Using CSS3 and progressive enhancement Multiple columns by filtering the_content More flexible multiple columns Multiple loops displayed in multiple [...]

Add Classes to post_class

The post_class() function in WordPress is pretty darn useful. It is used like this, in most templates, in a wrapping div of all the content you are outputting: <div <?php post_class() ?> id=”post-<?php the_ID(); ?>”> <!– Post stuff –> </div> I was in a circumstance where I wanted to add an additional class to what [...]

Shortcodes in Widgets

I had occasion the other day to run a shortcode inside of a text widget. You know shortcodes… we talk about them all the time. They are keywords in [square brackets] that do something special. Sometimes something really simple like returning a string (so you can have a global location to change that string) or [...]

How to Add Your Plugin to the WordPress Plugin Directory

Getting your plugins listed in the official WordPress Plugin Directory is considered a chore by many, but it’s nothing that should stop you from sharing your plugin with the community at large. Up until now, I haven’t really bothered with adding my plugin collection to the Directory, but after Herb Goodman helped to package my [...]

Change Quick Action Button in Admin

You know the “quick action” button in the WordPress admin? It’s a darn useful little UI touch. At the Dashboard, the default is “New Post”. But depending on where you are in the Admin, the default of it changes. In general it’s really helpful. For example when you are in the Plugins area, the default [...]

Digging Into WordPress v2.0 + Print is Back! (Oh, and a fresh new design!)

Version 2.0 is here! If you have already purchased the book, you have already gotten an email with a link to download the 2.0 version of the book. If you have been waiting for the print version to come back in stock, the time is now! We sold out of the print version the first [...]

WordPress Defender: 30 Ways to Secure Your Website

Looking for a good book on WordPress security? If so, we’ve got great news! John Hoff’s new security e-book WordPress Defender provides 30 practical ways to secure your website from the evil forces of spam, bad bots, and malicious hackers. The book is packed with practical, common-sense security techniques that virtually any WordPress user can [...]

Custom Comments HTML Output

Displaying all the comments on a Post is incredibly easy. In your single.php file you probably have a line like this: <?php comments_template(); ?> That line basically calls/includes your comments.php file. Within that, the line to output all comments is something really simple like this: <ol class=”commentlist”> <?php wp_list_comments(); ?> </ol> But that doesn’t leave [...]

Display Separate Counts for Comments, Pingbacks and Trackbacks

In WordPress, there are three ways to respond to a post: you can leave a comment, leave a trackback, or just link to the post to create a pingback. When displaying all of the responses to your posts, it’s a good idea to separate the comments from the pingbacks and trackbacks. Uninterrupted comment threads are [...]

Which Template File does WordPress Use to Render Different Pages?

This page in the codex has a particularly interesting infographic that shows a flowchart of how WordPress chooses which template file it is going to use to render the page. For example, did you know if you have a published page with “contact” as the slug, it will look for and use page-contact.php automatically? Unfortunately [...]

BLANK WordPress Theme

There are many like it, but this one is mine. I have a “blank” WordPress theme for myself, because I make a lot of WordPress themes. Starting from Kubrick, or any other pre-made theme, would be absurd. There is to much stuff there that would to be stripped out or fought against to be useful. [...]

Stop Spammers and Other Scumbags with a Custom Blacklist

I usually reserve most of my blacklisting content for Perishable Press, but after posting about using WordPress’ built-in tools to stop comment spam, several DiW readers have asked about a good custom blacklist that may be used for the “Comment Moderation” and/or “Comment Blacklist” features in the WordPress “Discussion Settings” screen. Over the years, I [...]

How to Widgetize Your WordPress Theme in 2 Steps

Working on a new theme for the next Digging into WordPress book update, I found myself really getting into the whole “widgetizing” thing. Widgets enable non-technical users to customize your theme according to their specific layout needs, and with so many different widgets available, the possibilities are endless. You may have thought about widgets as [...]

Custom CSS Per Post

I’ve long been a fan of “art directing” posts. That is, to apply unique CSS styling to an individual page of content when the situation calls for it. In the past, I’ve used the Art Direction plugin and I even created a screencast on using it. As it turns out, there is a major problem [...]

Remove Private/Protected from Post Titles

I had the situation come up where I need a password-protected post in WordPress. Of course that is super easy in WordPress, you can set up a password for it right in the “Publish” box before publishing. But by default, WordPress appends “Protected: ” to the front of the post title, before and after the [...]

WordPress Tip: Remove nofollow Attributes from Post Content

If you have posts that include the nofollow attribute on links, you may at some point decide to remove them. By default, WordPress doesn’t insert nofollow attributes in post content, but there are a variety of plugins that will insert nofollow into all links in post content. Or perhaps you have been manually adding nofollow [...]

Rounded Font-Sizes (with Colors!) for Tag Clouds

Tag clouds accomplish their varied font sizes by applying inline styling to each tag. The resulting font sizes can be really weird like style=’font-size:29.3947354754px;’. There is nothing inherently wrong about that, but it feels a bit unsettling and less controllable. Mike Summers sent in a solution he uses on his own site. Let’s check it [...]

New Poll: How Do You Use the WordPress Media Library?

For this DiW Poll, we ask the question: Do you use the WordPress Media Library, and if so, how much? On its own, the WordPress Media Library provides users with a wide variety of great tools for managing media content. The Media Library makes it easy to upload media content such as images and video [...]

Leave Comments Open Forever on Specific Categories or Page Templates

I like the idea of shutting off comments after a certain number of days. Here on Digging Into WordPress we do it after 90. After that kind of time, the “community” of the discussion is long over. I think a good practice for turning off comments is to instead leave a message informing visitors that [...]

Custom Query Shortcode: Run a Loop inside Any Post/Page

I had the occasion yesterday to have a page with a section on it where it would output a very specific set of other pages, which would need to change dynamically. What I could have done is built a special page template for this page, and inside that template run a query_posts() to get these [...]

Sold Out

The first printing of the print version of our book is sold out. We are in the process of updating the book to add all the new stuff up to WordPress 2.9.1, as well as some new secret awesome bonus stuff. We’ve decided to hold off on the second printing until that is ready (next [...]

Google Maps Shortcode

David Hollander of SparkWeb Interactive sent us in a little code clip for inserting Google Maps into Posts/Pages by the use of shortcodes. Google actually has copy-and-pastable iframe code already in Google Maps that is really easy to snag, but David was having problems with the Visual text editor screwing up the code when saving [...]

Poll Results: How Many Plugins do You Use?

Back in October, we asked the WordPress community How Many Plugins do You Use?. Several months later, over 1300 people have voted, and here are the results: I find these results to be very interesting. Looking at the data, we see that 63% of voters use 10 plugins or less. Further, a whopping 84% of [...]

Feature/Bury Comments

In my WordPress Wishes post, I mentioned something I thought would be cool: the ability to “feature” or “bury” comments. This would be very simple, just a few extra links when viewing the comment moderation list in the Admin area. The result would just be extra CSS class names applied when the comments list is [...]

Include the Category ID via post_class

The default output for WordPress’ post_class template tag includes class names for just about every type of page view imaginable: page-parent search-results logged-in author paged Plus just about everything else except for category ID information. It gives some good category-specific class names, but nothing to represent the category ID. For example, including the post_class function [...]

Why All-In-One SEO Deactivates

In the past I’ve been pretty pissy about the All-In-One SEO plugin from Michael Torbert automatically deactivating itself after updates. My reasoning: If you update and forget to re-activate (somewhat hard to do since it reminds the shit out of you on every page of the admin), it could cause problems. We are forced to [...]

WordPress Wishes

Happy New Year all! I’m looking forward to what will hopefully be an awesome year, with WordPress and otherwise. I thought I’d take the opportunity to wish-o-wish upon a star and toss out some things I think would be really cool to see happen in the WordPress world. Subscribe To Comments, rebuilt for modern WordPress [...]

Cool Things You can do with the WordPress “more” Tag

Our personal collection of useful ways to customize and format the WordPress more tag… Everyone who has been using WordPress for any length of time should be familiar with the <!–more–> tag. When you are writing a post, inserting the <!–more–> tag within the post text will create an excerpt out of any text/markup that [...]

The Book, in Print!

If you have been waiting to buy the book until the real print version is available, today is the day! The print version of Digging Into WordPress the book is now available here. We’ll probably talk more about the journey through the entire process of creating this book at a later date, but for now, [...]

How to Develop WordPress Themes Behind the Scenes

A reader recently asked about how to develop a theme on a live site such that: All visitors will see the current theme Only the designer will see the new theme All site plugins will work with the new theme Smooth transition between old and new theme at launch These are the main concerns, but [...]

Display Gravatar & Autofill Fields for Previous Commenter

When someone comments on your site, cookies with the information the entered are saved to their computers. WordPress makes it easy to access that information. In fact, in your comments.php template they are ready-to-go PHP variables you can spit out anywhere you’d like. Let’s take a look. Here are the most important ones, when it [...]

Optimizing WordPress Post Navigation

Implementing a solid set of navigational links for your WordPress site is one of the best ways to encourage visitors to stick around awhile and check out additional content. As discussed in our definitive guide to WordPress post navigation, there are essentially three different types of navigational tags for WordPress: Index and archive navigation: posts_nav_link() [...]

Two Ways to Limit the Number of Posts without a Plugin

Let’s say your blog is set to display ten posts per page, as specified via the WordPress Admin under Settings > Reading. Once set, ten posts will appear on your home page, archive pages, search results, and so on. In other words, if it isn’t a single-view page or an actual “page” page, you’re gonna [...]

Redirect Mobile Users to a Mobile WordPress Theme

Let’s say you want to have a special theme for your WordPress site for mobile users. You don’t want to use a pre-canned solution or anything third-party, you just want to create and design the theme yourself. So what you need to happen is for the site to detect mobile users and server up an [...]

Remove Title from Blogroll

Typically when you use one of WordPress functions to output a list of “stuff” from WordPress, you can pass a parameter to eliminate the “title” that WordPress likes to put in there by default. For example, with wp_list_categories you pass along “title_li=” with nothing after the equals sign to remove the title that normally accompanies [...]

Create a Custom Database Error Page in WordPress

As a dynamic blogging system, WordPress consists of PHP files (the WP core) that interact with a MySQL database to generate the web pages for your website. When everything is working properly, this dynamic interaction keeps WordPress humming along like a champ, but when your database crashes, WordPress can’t operate and will deliver the following [...]

Media Temple, WordPress, Mass Hacking

Update: Media Temple is saying that: They aren’t 100% sure the cause, but yes, it is their fault. About 10% of all (gs) users were affected. It’s not WordPress specific, it’s PHP specific. Definitely change your passwords, definitely don’t change it back to the original password. A number of people (Michael Torbert, Kyle Brady, Jeffrey [...]

How to Import and Display Feeds in WordPress 2.8 and Beyond

Importing and displaying feeds in your WordPress themes is a great way to share additional content with your readers. Some good examples include: Displaying your latest tweets, flickrs, or delicious saves Displaying content from your other sites in your sidebar or footer Providing a public link feed to which your readers may contribute or subscribe [...]

Make an Infinite More-Posts Section

The goal here is to make a list of posts in the sidebar that show a number of recent posts. There will be a button you can click which will replaces those links to recent posts with older posts, AJAX style. You can keep clicking the button and keep getting older and older posts. On [...]

How to Disable Comment Feeds for Individual Posts

By default, WordPress generates a RSS feed for the comments on every post. Many sites take advantage of this by offering the feed next to the comments area, enabling anyone to stay current with conversation. A typical feed menu for many blogs includes the following items: Main Content Feed (posts, articles, etc.) Main Comments Feed [...]

Find Typos? Other Mistakes?

Going the self publishing route with our book meant that we didn’t have a big fancy book editor going over our text. We of course strive to be the best writers we can be, but we are clearly better WordPress wranglers than we are wordsmiths. If you find any typos or any other kind of [...]

It’s Here!

Jeff and I launched this blog back in May of this year, after we decided we were going to self-publish the WordPress book we were working on. After weighing all the options, we decided going it on our own was best because we would have 100% control over everything. From the content of the book, [...]

How to Secure Your New WordPress Installation

One of the best ways to ensure strong security for your WordPress-powered site is to secure its foundations during the installation process. Of course these techniques can be implemented at any point during the life of your site, but stetting them before the game starts prevents headaches and saves time. We’ll start with the WordPress [...]

You Don’t Need Any Plugins to Stop Comment Spam

I think one of the biggest WordPress myths is that you need a bunch of plugins to control comment spam. Pretty much all of the posts out there on preventing WordPress comment spam are telling you to install some list of “must-have” anti-spam plugins. Some authors insist that you need only a few “choice” plugins, [...]

WP Typo Abound!

The month of November is National Novel Writing Month (or #NaNoWriMo). Joel Goodman is participating and thought that the WP Typo theme would be a good fit for it. Joel has expanded upon theme, offering an options page with various different typography choices, better integrated site registration, and some design tweaks. It is now called [...]

Custom Fields for HTML Post Titles

You don’t want to go putting HTML tags directly into post titles. It might show up OK on your own site, but it can be problematic. For example, your titles through RSS will show the tags as next, not render them. I was wishing for a plugin to handle this better, but until then, here [...]

The Difference Between is_singular() and is_single()

You know that you can target single-view pages with the conditional tag, is_single(): <?php if(is_single()) { // do something } else { // do something else } ?> This is a great way to conditionally apply styles, scripts, and markup to single-view pages. But did you know about the conditional tag, is_singular()? The is_singular() tag [...]

Multiple the_date() Functions Return Empty Date

Inside the loop, if you use the function the_date() to display the date the post was published, you may run into trouble. Specifically, if there are two posts published on the same day, the second one will return nothing for a date. To fix this, use the_time() instead. There is quirk though, as the_time() ouputs, [...]

New Poll: How Many Plugins do You Use?

Time for a new poll! This one is something that many WordPress developers and designers think about: how many plugins is the right number of plugins? Of course there is no one correct answer, but it will be interesting to see if there is a particular number of plugins that most people are using. If [...]

Plugin Wishes Come True

Just a quick update to the post I wrote about plugins I’m too lazy to write. Steve Whiteley put together a plugin for Subtitles that is exactly how I envisioned it. For my wishes about avoiding widows in post titles, Shaun Inman had the solution years ago. (Shaun’s site is down for me right now, [...]

Rude Things Plugins Can Do

I heart plugin authors. Their work is generally amazing, a huge benefit to the community, the reason why WordPress rules so much, and deserving of much worship. That being said, plugins can do some pretty rude things sometimes… Deactivate Themselves I had a plugin that I used that liked to deactivate it itself when you [...]

Poll Results: Goodbye Dolly

Back in July, we asked the WordPress community whether or not the Hello Dolly plugin should be included with WordPress. Several months later, over 1,200 people have voted, and here are the results: I’m not going to say too much about this, as I think the results speak clearly enough. Many of the comments on [...]

Ideas for Plugins I’m Too Lazy To Write

… or slightly more accurately, that I don’t know how to write =) Subtitle I think it would be a cool format for a blog to have a title and a subtitle for every single Post. You could easily do it with Custom Fields, but this plugin would alter the Admin screen for writing posts [...]

Five Ways to Change Your WordPress Password

With the dynamic nature of WordPress, creating, using, and maintaining strong passwords is critical. Passwords help keep the good guys in and the bad guys out, enabling you to run a safe, secure WordPress-powered website. In this DiW tutorial, we’re going to show you how to change your WordPress password in virtually any scenario: logged [...]

Clean Up Empty Elements with CSS 3

By default, WordPress wraps HTML comments with paragraph tags: WordPress also employs various template tags that may, in certain situations, result in empty HTML elements such as paragraphs tags: <p></p> <p><!– –></p> Other cases where empty elements are generated by WordPress involve images, line breaks, nested lists and other complex markup scenarios. Besides invalid markup, [...]

Easy Shortcode Permalinks

When you are building a theme, and the circumstance comes up where you need to create a link to a specific page hard-baked right into the theme, there is a function you should be using. Not great: <a href=”/contact/”>Contact</a> Much better: <a href=”<?php echo get_permalink(12); ?>”>Contact</a> That “12″ would be the ID of the Post [...]

Integrating Fading Button Navigation

I was talking with Darren Hoyt recently about building a better interactive button. The goal of the button was to provide three states: regular, hover, and active (pressed). That is standard of any good button, but we were going to integrate some fading effects into it to really making the button satisfying to interact with. [...]

Precision Targeting with Custom Action Hooks

WordPress’ powerful action-hook system makes it possible to insert functionality at any point in your theme. Most WordPress themes include some of the built-in WordPress hooks by default. For example, most of us are aware of the two most common WordPress hooks: wp_head() and wp_footer(), which generally appear in the theme’s header and footer sections. [...]

Global Custom Fields, Take Two

Just as I hoped, someone wrote in with a far nicer solution to my Global Custom Fields solution than I originally had. Big thanks to David Hollander for this. Options Table Turns out we can post values to options.php and literally save them right to the options table in the database. We can add a [...]

How To: Breadcrumbs in WordPress

I’ve always used plugins for breadcrumbs, but of course rolling your own is always appealing. Gilbert Pellegrom shows us how to do it with our own custom functions. Update: apparently the page is no longer active. If anyone knows an alternate location of Gilbert’s post, please let us know. Thanks. Dead link: http://www.gilbertpellegrom.co.uk/how-to-breadcrumbs-in-wordpress/ Update: Thanks [...]

Global Custom Fields

UPDATE: Make sure to take out “Take Two” on this concept, with a cleaner method for doing this. Custom fields allow us to attach data to Posts or Pages that we can yank out and use at will in our templates. They are awesomely flexible and single-handedly allow WordPress to be used for about any [...]

Easy Custom Feeds in WordPress

Now that we have seen how to setup Tumblr-style posts, it would be nice to be able to segregate the Tumblr-posts category from the main feed into its own, separate feed. This would enable readers to subscribe exclusively to the Tumblr-posts feed and maybe display it in their sidebar or something. While we’re at it, [...]

Embed an MP3 Widget of Any Song (Legally)

Let’s say you were going to start a music review site where you review individual songs. Words are great, but in this context they aren’t going to mean much unless you have the song right there to go with it that can be listened to. This presents some interesting legal problems. You can’t just upload [...]

How to Implement Tumblr-Style Links for Posts and Feeds

Since posting the DiW tutorial on designing a Tumblelog theme for WordPress, several readers have asked for a tutorial on how to setup just the Tumblr/tumblelog-style post links …without having to implement the entire theme. So in this tutorial, I will extract the tumblelog-link information from the theme tutorial, simplify it, and enhance it to [...]

Look Ma, Editable Text Regions

WordPress is a CMS. The whole idea being to manage content and make websites editable without having to wrangle code. Any theme can handle Posts and Pages, but what about those “smaller” areas. Little chunks of text placed around a design like a small “about” section, or the copy in the footer of a website. [...]

How to Display a Copyright as a Range of Dates

Technically, your work is protected under copyright “the moment it is created and fixed in a tangible form that it is perceptible either directly or with the aid of a machine or device.” [1] Registration of your copyrighted work is not required [2], but you should include a copyright notice on all published works [3]. [...]

Plugin Spotlight: Postalicious

The social bookmarking service Delicious has always been friendly with WordPress. In fact, right from the settings of your Delicious account you can set up a blog posting “job” which will literally post your links directly to your blog with no intervention on your part (instructions on that here). Using this system to post directly [...]

Definitive Guide to WordPress Page Navigation

There are many ways to navigate a WordPress-powered site. There are archive links, category links, page links, internal post links, single post links, admin comment links, tag links, and many other types of navigational links. When it comes to navigating sequentially through your site’s chronological archive pages, category archives, and other types of archive pages, [...]

Password Protect More Than the_content()

WordPress has the ability to easily password protect the content of any Post or Page. Right over by that big juicy blue “Publish” button, there is an option for Visibility. Click edit, and you have the option to make it password-protected and set a password. What happens now? By default, WordPress will prepend “Protected: ” [...]

Advanced WordPress Targeting with body_class_plus()

Since WordPress 2.8, we can target specific types of page views with CSS using the new body_class() tag. Designed for use within the <body> element, body_class() outputs various class attributes according to the current type of page view. This makes it easy to apply page-specific styling such as current-page navigation highlighting and other nifty CSS [...]

WordPress Plugins That Are Useful for ANY Site

The whole notion of plugins is that they provide special niche functionality that not every site would need. But that is just theoretical, as most new features that have ever been added to the WordPress core began life as a plugin. If the plugin was useful to enough people, it was built in. In my [...]

Will This Work With WordPress?!?!

Yeah, it will. This is something I find myself answering a lot. Excuse the snarky introduction to this post, my real goal here is to attempt to clarify what will and will not “work” with WordPress. WordPress is a PHP application. PHP is a server-side language which does all the work that applications need to [...]

Awesome Image-Attachment Recipes for WordPress

Recently, I found myself on the front lines of WordPress’ somewhat complicated Media-Library system. The site that I was developing required a rather elaborate system of retrieving and displaying image attachments. So, using the latest version of WordPress (2.8.3 at the time), I found myself experimenting with as many template tags and custom functions as [...]

Breadcrumbs in WordPress

Breadcrumbs are such a standard design pattern these days I find it surprising there isn’t a build in WordPress function for displaying one. But no matter, that’s what plugins are for. A quick Google search brings up a couple. Yoast has one, so you know that one is pretty good. The other popular one is [...]

Show Off Your WordPress Database Statistics

Did you know that WordPress makes it super-easy to display some basic statistics about your database performance? The information may be displayed publicly on your web page, slightly hidden in your source code, or entirely private so only you can see it. There are two basic statistics that are drop-dead easy to include on your [...]

Goodbye Dolly? (Take the poll!)

Out of the thousands of plugins available for WordPress, there is one that all WordPress users are familiar with: Hello Dolly. As far as I know, the Hello Dolly plugin was the first WordPress plugin and has been included with every version of WordPress. The plugin is so familiar that many WordPress users don’t even [...]

Getting More Fine-Grained with Includes

I was recently putting together a site where I found it very useful to have a number of small areas of the site as separate chunks of code I could include in templates at will. The site wasn’t unusual at all, it just never occurred to me to get this fine-grained with includes before, but [...]

3 Ways to Monitor PHP Errors

Close monitoring of your site’s PHP errors is crucial to operating a healthy, secure, and well-performing website. When left undetected, PHP errors can reduce performance, waste bandwidth, and leave your site vulnerable to malicious attack. PHP errors usually occur unpredictably and spontaneously, and may be triggered by even the slightest changes to your server configuration, [...]

Commonly Useful Page Templates

I find on nearly every one of the many, many WordPress powered sites I take care of, I have at least a couple of special page templates that I set up and use frequently. No Title Sometimes it’s nice to have a page template available that doesn’t spit out the title at the top. I [...]

Mastering WordPress Post-Revisioning and Auto-Save Features

Not everyone loves the post-revisioning feature of WordPress. In fact, some people can’t stand it. On the one hand, it’s nice to have a library of post-draft revisions to drudge through if you should ever make a mistake. On the other hand, multiple copies of every post is a great way to bloat your database [...]

Display a Random Post (with AJAX Refresh)

I think you’ll be surprised at how ridiculously easy this is. We are going to leverage some serious smartness from both WordPress and from the JavaScript library jQuery. 1. Set up area for Random Post (HTML) This could be anything really, just so long as it is a text page element with an ID you [...]

How to Remove the WordPress Version Number (The Right Way)

One of the most commonly seen security tips around the WordPress-o-Sphere has got to be this: Don’t display your WordPress version number publicly Many WordPress developers often display the WordPress version in the source code. But having this information publicly available makes it easy for attackers to exploit known vulnerabilities on a particular WordPress version. [...]

Move Your WordPress Files Out of the Root Directory

I usually recommend that people install WordPress at the root directory of their sites. Even if you intend to mostly use WordPress for a blog, and run it at /blog/, you can still do that with WordPress at the root through some simple settings. But just because WordPress is installed and controlling your site from [...]

Delicious Recipes for WordPress Page Menus and Page Listings

There are so many awesome ways to display your WordPress pages. Out of the box, WordPress provides two different template tags for displaying lists of your site’s pages. The first, most-commonly used tag is wp_list_pages(), and the second, lesser-known tag is wp_page_menu(). First we’ll explore the highly flexible wp_list_pages() template tag, and then we’ll dig [...]

Making an Expanding Code Box

On blogs that like to share snippets of code like this one, it is common to use the <pre> tag to wrap the code so that the spacing/indenting is maintained and long lines do not wrap. While this is desirable behavior, it can be undesirable to have those un-wrapped lines break out of their containers [...]

Optimize WordPress Performance with the wp-config.php File

As you may recall, there are a ton of configuration tricks available for the WordPress wp-config.php file. So many in fact, that I think many people may have missed some of the choice definitions aimed at optimizing WordPress performance. In this post, we’ll explore the best ways to improve your site’s performance with WordPress’ wp-config.php [...]

How to Design a Tumblelog Theme for WordPress

Tumblelogs are a great way to streamline mixed-media blogging for different types of content. Commonly used tumblelog topics include “Links”, “Photos”, “Quotes”, “Dialogue”, and “Video”. A good tumblelog presents each these different topics with its own unique format while retaining an overall sense of cohesion throughout the entire design. A good example of this involves [...]

Putting the_content() into a PHP Variable

There are probably a couple ways to do this, but here is a really easy one: ob_start(); the_content(); $content = ob_get_clean(); This is called “output buffering” where the output is redirected from being directly sent out to being written to a buffer. Why? In case you need to do any manipulation or calculation of the [...]

Free HTML 5 WordPress Theme

In an effort to inspire more WordPress theme designers to embrace HTML 5, I am releasing the “H5” Theme Template. The H5 Theme Template is a bare-bones WordPress theme built entirely with HTML 5 and styled with CSS 2.1. As you may know, HTML 5 provides greater flexibility and interoperability than previous markup languages, and [...]

Spam Link Injection Hacked (and How I Hopefully Fixed It)

Just recently my other blog CSS-Tricks was hacked. I first found out by a very helpful reader emailing me a screenshot from the mobile version of my site. The mobile version of my site was built by Mobify, so I contacted them right away. As I should of known, of course Mobify can’t insert content [...]

WordPress Configuration Tricks

Many WordPress users know the wp-config.php file as the key to the WordPress database. It is where you set the database name, username, password, and location. You know the one: The wp-config.php file contains the information required for WordPress to connect to the database But what many users don’t know is that the wp-config.php file [...]

Use Google-Hosted JavaScript Libraries (…still the Right Way)

I previously posted on how to include jQuery in your WordPress theme the Right Way. That is, to use the wp_register_script function to register the script first. It’s literally a one-liner in your header.php or functions.php file, but by default, it loads the internal version of jQuery that ships with WordPress. It’s all the rage [...]

The xmlrpc.php File and Site Security

Located in the header.php file of most WordPress themes, there is an important hook called wp_head(). This essential hook enables functions to output content to the browser in the <head> area of the web document 1. In newer versions of WordPress, this hook enables WordPress to output the following three lines to your theme’s <head> section 2: [...]

Add/Remove Buttons from WordPress Write Panel

One of the features of WordPress 2.8 was a “increased speed of the Admin area”, which cited compressed JavaScript files as the reason for the speed increase. One of those files that was compressed was the file quicktags.js in the wp-includes/js directory. When you have the visual editor turned off, this is the file responsible [...]

Create a Stunning Lightbox-Style Random-Post Header Gallery

In this tutorial, we’re going to take advantage of two of WordPress’ most powerful features, get_posts() and custom fields, to create a stunning random lightbox-style header gallery for your post images. Displayed before the standard post loop, this lightbox gallery will randomly display the images that are associated with your posts while also providing a [...]

Free Theme: WP Typo

A big thanks to everyone for being supportive of the launch the website launch for Digging into WordPress. As thank you, and to celebrate our launch, I’d like to present to you a brand new free WordPress theme for you to download. It’s called WP Typo. You can view the demo here and download the [...]

Edit Your Database Options from the WordPress Admin

Ever needed to update an option in your database without having to log into your control panel or phpMyAdmin? WordPress provides you with an easy way to view, edit and update your database options table (wp_options) by simply opening the following URL in your browser: http://your-blog.com/wp-admin/options.php Edit the URL with your domain name and hit [...]

Welcome!

Thanks for the warm welcome everyone!

Version 2.8 is Now Available!

Just minutes ago, WordPress Version 2.8 was released! As usual, there are a ton of new features, although much of it affects developers and back-end types more than it does designers or casual bloggers/users of the Admin area. Here are some related links: The Codex for v2.8 (Full feature list) Plugin Compatibility for 2.8 Theme [...]

Redirect Dead-End Category, Search and Tag URLs

Beginning with version 2.5, WordPress automatically handles many types of canonical redirects. A good example of this may be seen by typing your blog address into your browser both with and without the www prefix. If you are using WordPress 2.5 or better, one of these versions of your blog URL will be immediately redirected [...]

Including jQuery in WordPress (The Right Way)

If you want, you can just download jQuery, put it on your server and link to it from your header.php file in the <head> section. But that can cause you grief. For one thing, some plugins use the jQuery library, and they are going to load it as well. This can cause problems. How was [...]

Custom WordPress Title Tags

By default, WordPress provides a decent way of including <title> information for your posts, pages, and various archive views. Using WordPress’ built-in template tag, “wp_title()”, we can specify several useful parameters, including: sep – a string value indicating the separator displayed before the title echo – a boolean value determining whether or not the title [...]

Unique Body ID’s for your Pages

There are many reasons you might want to get a unique ID for your tag. Let’s say you want your header elements to be a different color on your About page, you could style: h3 { color: blue; } body#about h3 { color: red; } But how do you get that ID on the About [...]

Dynamic Copyright in your WordPress Footer

Many footers on websites contain text like “© 2009 Your Website”. A good measure, surely. We can use some classic PHP and a built-in WordPress function to make this bit of text dynamic so that it will never need to be tampered with manually again. <p> &copy; <?php echo date(“Y”); echo ” “; echo bloginfo(‘name’); [...]

Typography Test

Header Level 3 Header Level 4 Header Level 5 Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et [...]

Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!