Database Powered CSS in WordPress Themes
“A popular ability in WordPress themes is to add custom CSS driven by options. This brings up a common question, how should the theme inject custom CSS? I’ll outline three different approaches on how to do this.”
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 of the most prevalent PHP applications on servers today.
Display “Time Ago” for Posts or Comments
Turn regular datestamps into more human-readable text (e.g. 22 minutes ago) via a built-in WordPress function.
Custom Post Types in WordPress 3.0
Still confused about these “custom post types”? We already have categories for Posts and we can use various techniques like post_class to target certain posts with CSS and do different styling. We can also use conditionals to treat posts in different categories completely differently. Why is this going to help?
The big difference is that it actually adds sidebar links to the Admin side specifically for these new types. And beyond that, you can actually declare custom data types for different types. Instead of just “Add Post” and “Add Page”, you can have “Add Real Estate Listing”, which only will ask for “Property Name”, “Description”, “Price”, and “Sale Status”. Powerful stuff!
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:
.net Mag, The web pro’s guide to WordPress
I just got my hands on issue #199 of .net Mag. I did an article for it on WordPress, and it’s on the cover!
They did use the wrong W for the cover, but I’m sure they got enough flack for it they won’t mess that up again =). This is probably practically an old issue for UK folks, but big bookstores in the U.S. I find do tend to stock this magazine (Sold as “Practical Web Design” in the U.S.) but always a few issues old, so I bet you could find it around about now.
Editor’s note: 404 link removed.
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 there. This takes care of all those little things that always need to be done for every theme. You know, things like:
Declare Multiple Widgetized Areas in WordPress
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 widget-heavy theme I am working on.
WordPress Admin Bookmarklet
Drag to your bookmarks bar, click, get a bunch of buttons for easy access to specific areas of your WordPress admin. No security concerns, other than taking people to your log in page, so assuming you have a good strong password you are fine. Also I suppose this assumes you have WP installed at the root…
5 tips for using AJAX in WordPress
WordPress has a bunch of AJAX abilities built in that you can access, without having to use any outside resources. Gary Cao shows how, pointing out good and bad practices.
Editor’s note: 404 link removed.
6 Ways to Display WordPress Post Content in Multiple Columns
Most blogs display their post content in single columns, like what we do here at Digging Into WordPress. But you know it’s also possible to display post content in multiple columns. Multiple-column layouts are perfect for newspaper and magazine-style themes. This DigWP article presents six ways of getting the job done using a variety of techniques, tricks, and tips.
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:
WordPress vs. ExpressionEngine: Apples and Oranges?
Marcus Neto attempts to compares the two CMSs while explaining why he likes ExpressionEngine. Are they really apples or oranges? I suppose you could say that. Apples and oranges are both popular spherical fruit. They have more in common than theyhave different. Same with the two CMSs.
While I’m 98% a WordPress guy, there are a few circumstances I might take the EE route, like when:
- I knew I was going to need a whole bunch of different custom data types and groups and didn’t feel like dealing with the whole Pods or Flutter setup.
- I also knew no newbie client was going to need to get in there.
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 they do something really simple like return a string (so you can have a global location to customize some string of text, for example), or they do something more complicated like call a plugin that does something fancy like build a photo gallery.