Like the blog? Get the book »

Posts tagged: tricks

Archive page 6 of 6
Awesome Image-Attachment Recipes for WordPress

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 I could find. After much experimentation, I discovered the perfect solution, and along the way I collected a healthy collection of recipes for displaying image attachments and their various types of associated information.

Show Off Your WordPress Database Statistics

Show Off Your WordPress Database Statistics

Hello WordPress peeps! 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 pages:

Getting More Fine-Grained with Includes

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 I’m starting to do it now and I like it.

Commonly Useful Page Templates

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.

Display a Random Post (with AJAX Refresh)

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.

Move Your WordPress Files Out of the Root Directory

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 when WordPress is installed in the root directory. It’s just a matter of changing some simple settings. But just because WordPress is installed and controlling your site from the root directory, that doesn’t mean that the WordPress core files need to be located in that same location.

Making an Expanding Code Box

Making an Expanding Code Box

On blogs that like to share snippets of code like this one, it is common to use the <pre></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 awkwardly and overlap other content.

Optimize WordPress Performance with wp-config.php

Optimize WordPress Performance with wp-config.php

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

Putting the_content() into a PHP Variable

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();
WordPress Configuration Tricks

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 (among other things like security keys, database prefix, and localized language).

Here’s a screenshot of wp-config.php (aka the WordPress configuration file) for those who may not yet be familiar:

Edit Your Options from the WordPress Admin

Edit Your 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:

© 2009–2024 Digging Into WordPress Powered by WordPress Monzilla Media shapeSpace