Home About the Book About the Authors Handy Links

WP-Print

Maria.

One of the things that bugs me a little about WordPress is that when you print a page, the resulting printout does not have the same formatting as the page in your Web browser. Instead, styles are pretty much stripped out and sidebar components are added to the end (at least in my case) to the printout. This makes the printout longer than it needs to be.

Enter Lester Chan’s WP-Print plugin. It enables you to add a Print link to your posts. When a user clicks the link, the plugin creates a simply formatted page with the page contents and URLs. You can then click a link on that page to print the formatted page.

I just installed this feature on my personal site, if you want to check it out for yourself.

Comments Off

WordPress Maintenance

Miraz.

I’ve been investigating why the MySQL database behind my TiKouka blog has been ballooning recently and uncovered some interesting facts:

  1. My blog’s being bombarded by spammers at the moment. Spam Karma’s doing a fantastic job of keeping the spam comments away, but retains them for a user-definable period and purges the logs at user-defined intervals. I’ve been reducing both those intervals — they are now down to 2 days — but even so the comments and logs take a fair space — currently something like 40Mb.
  2. In early April I installed the WP-Shortstat plugin. It keeps logs of visitors to the blog. I just disabled the plugin and deleted a table containing more than 100,000 entries. That slimmed the database by 20 Mb!
  3. I just came across yet another useful page on the Codex: WordPress Site Maintenance:

    To keep WordPress working like a the finely honed machine that it is, there is some site maintenance we recommend you do frequently. Consider it the lube job you need once every 1000 miles.

Comments Off

WordPress Podcast

Maria.

I just did an episode of my Maria Speaks podcast about WordPress. You can download the podcast’s MP3 file by clicking here or read the following transcript.

Episode 25 of Maria Speaks.

Hi, I’m Maria Langer. Welcome to Maria Speaks episode 25: WordPress.

First of all, I have to apologize for not keeping up with the podcasts as promised. Although I have plenty to write about in my blogs, I don’t seem able to get it together for a podcast. I know there are podcast subscribers out there waiting for new content, but none of them have provided any feedback about what they’d like to hear. So I’m just kind of floundering around without guidance, waiting for someone to give me an idea.

To make matters worse, I had a bit of surgery early in May and have been recovering more slowly than I expected. I’m okay — I’m just a little slow — and you can take that any way you like because it probably applies. It’s very frustrating for me. I can’t wait until everything’s healed and I can really get on with my life.

Today I decided to do a podcast about WordPress. Those of you who read my blog know that I use WordPress now to create and maintain not just my blog but my personal Web site and my book support Web site. You also might know that I’m co-authoring a book with Miraz Jordan about using WordPress. The book, which is for Peachpit Press, is called WordPress 2 Visual QuickStart Guide and it should be in stores by June.

WordPress is, on the surface, a blogging platform. With PHP, MySQL, XHTML, and CSS under the hood, it offers an easy-to-use, Web-based interface for adding posts, managing categories, handling comment moderation, and performing other blog-related tasks. A novice user can use WordPress without knowing a thing about what’s under the hood. But a user with some knowledge of HTML and CSS could go nuts customizing the blog’s appearance. Add a little knowledge of PHP and plugins available to WordPress server installations and the sky’s the limit on blog customization.

But WordPress is more than just a blogging tool. It’s a complete content management system. That means you can use it to build an entire Web site, with static pages and navigation. This is what I’ve done with the two sites I recreated with WordPress: marialanger.com (where you can find the transcript for this podcast) and wickenburg-az.com. WordPress is a perfect tool for maintaining a Web site that needs fresh content added regularly because its blog format automatically displays new content on the home page and archives old content so it’s always available. No need to code HTML and manually revise pages. WordPress does it all for you.

When I first started using WordPress last year, I got very excited about it very quickly. Finally, a Web publishing tool that gave me the power to create my own custom solution without knowing XML. (I never did bother to learn XML or JavaScript, both of which are popular programming languages for Web publishing.) I realized that I could customize my sites little by little, tweaking them to meet my needs. It was a dream come true — a Web publishing project that I could work on forever without it ever looking only partially completed.

Best of all, WordPress is open source software built with open source software. That means its free for most uses.

WordPress comes in two versions: WordPress.com and a WordPress server installation. Let me take a moment to explain the differences between the two.

WordPress.com is a Web site built and maintained by the WordPress development team. Users can create a free WordPress.com account and immediately start blogging. There’s no need for a server or a domain name or any knowledge of any programming languages. WordPress.com bloggers have some control over the appearance and navigation options of their blogs, so they can personalize them to some extent. A WordPress.com account is a great, free way for novice bloggers — or bloggers on a budget — to get their words out.

A WordPress server installation requires the blogger to either install WordPress on his own server or on an ISP’s server. This requires a bit of technical know-how, as well as certain versions of MySQL, PHP, and an Apache-compatible Web server to be installed on the server. It isn’t difficult to do — after all, I managed to do it on a spare Macintosh G4 running Mac OS X Tiger server. But you can also set it up on an ISP’s server if the server meets the minimum system requirements. I was able to set it up, for example, on a GoDaddy.com hosting account. A WordPress server installation is a costlier and more complex way to use WordPress, but it does give you complete control over the way your WordPress-based Web site looks and works. Only through a server installation can you fully customize theme files and install WordPress plugins.

No matter how you set up your WordPress blog, it’s easy to create blog entries and static pages. Just use a Web-based form with just about any Web browser — I prefer Firefox — to compose and edit content. The blog’s administrative interface gives you access to all the tools you need to set up categories, moderate comments, add links and blogrolls, and manage user accounts. WordPress.com server installations support multiple blogger accounts for a blog, making it great for a site that’s built and maintained by multiple people. Content appears online immediately, as soon as it’s published.

It’s also easy for blog readers to enter comments about your entries — if you allow commenting. This creates a dialog between you, the blogger, and your readers. (A two-edged sword sometimes!) Both types of WordPress installations have comment spam prevention tools, so you don’t have to worry much about comment spam.

There are millions of blogs out there, millions of bloggers sharing their thoughts with readers. If you’ve always wanted to be one, why wait? Visit WordPress.com to get started.

But if you’re like me and are just looking for that perfect Web publishing tool to make your sites easy to build, customize, and manage, a WordPress server installation may be just what you need.

Comments Off

Splitting a Category List

Maria.

When I rolled my book support Web site, LangerBooks.com, into my personal site and blog, I needed to make a clear distinction between the categories that I maintained to support my books and those that were part of my blog. I wanted to make it very easy for readers looking for more information and support to find the information they sought. I achieved this goal by displaying the two groups of categories separately, each under its own heading.

Check out the sidebar on the site to see for yourself. The Book Support heading lists all book support categories (one per title that I support). A list of links appears under the Publisher Links heading that comes next. Then the Maria’s WebLog heading lists all categories that are part of my WebLog.

I could think of two ways to do this with WordPress. Unfortunately, I chose the hard way.

To get the category list in the sidebar, I included the wp_list_cats tag in the sidebar.php file. (Forgive me for not going into detail about that — Miraz and I cover it in detail in our upcoming WordPress book.) I prefer wp_list_cats over list_cats because I find it easier to enter the arguments in the single string format it offers.

The first (hard) way to separate the category list into two groups is with the exclude argument. For example,

wp_list_cats('sort_column=name&optioncount=0&exclude=10,15')

instructs WordPress to list all categories, sorted by name, without post count, except categories 10 and 15. To make this work, I had to construct two separate commands: one for Book Support that excluded the Maria’s WebLog categories and one for Maria’s WebLog that excluded the Book Support categories. At the time, this seemed to make sense, since I was not using a category/subcategory structure and I didn’t expect to add any more categories. In reality, I was just being lazy — and I paid for it.

Of course, I did add more categories. And what do you think happened? The new category was listed under both headings because it hadn’t been excluded from either one. So every time I added a category, I had to tweak one of the two lines of code in the sidebar.php file. Not exactly something I wanted to remember to do.

So I did it the smart (right) way. I created two new categories: Book Support and Maria’s WebLog. Then I went into the Manage Categories administration panel and I edited every category (other than the two new ones) so it was a subcategory of one of the new ones. Finally, I went back into the sidebar.php file and replaced the two original wp_list_cats lines with a line like this:

wp_list_cats('optioncount=0&child_of=35&sort_column=name')

This says to list all categories, without a post count, that are the child (subcategory) of category 35, sorted by name.

Now every time I add a new subcategory, all I have to do is immediately assign it to the correct main category. It will appear under the correct heading. Quicker, easier, and it works.

Of course, you can split your category list by as many parent categories as you like. You don’t even have to list them all in the sidebar. This seems to be the best way to do it. Give it a try and see for yourself.

Oh, and by the way, you can learn more about the wp_list_cats tag in the WordPress Codex. The Codex is an excellent source of information about WordPress with just two tiny problems: some information is a bit tough to find and other information isn’t exactly up to date. But the template tag information is right on target and easy to find.

Comments Off

WordPress sitemap

Miraz.

I was thinking it would be good to have a reference page on my Learning Centre listing all articles by category. I started by creating a new archives.php template. Then I rummaged round in the WordPress Codex for a while trying out various template tags and all. Ultimately though, I couldn’t see how to achieve what I wanted so I started Googling.

Fairly quickly I found the most excellent Sitemap Generator Plugin:

This plugin allows you to create a sitemap for your WordPress powered site. This is not just another XML sitemap plugin, but rather a true sitemap generator which is highly customizable from its own options page in the WordPress admin panel. Some of its features include: support for multi-level categories and pages, category/page exclusion, multiple-page generation with navigation, permalink support, choose what to display, what order to list items in, show comment counts and/or post dates, and many other options.

A quick and easy install, some setting of the options and a smidgeon of tinkering with my stylesheet has produced: Learning Centre Articles by Category.

Displaying Random Ads

Maria.

I’ve been wanting to do this forever. In fact, it was the first thing I explored when I started using WordPress late last year. Unfortunately, I didn’t have enough understanding of how plugins and theme files worked to get anywhere.

Things are different now. I know what I’m doing. And this particular task is quite simple, as you’ll see here.

The Goal

My goal was to be able to display small advertising images at the top of the navigation bar. The image would appear randomly from a pool of images and, when it appeared, it would be associated with a specific URL. When the image appeared, the site visitor could click the image to go to a Web site or page.

I wanted to use this for wickenburg-az.com, a site I spend an awful lot of time working on with no compensation. The idea was to charge a nominal fee to add an image to the pool for a month. The money I collected would cover the cost of running the site.

Keep in mind that I could use any size image and place it anywhere in the header, sidebar, or footer. I wanted a 170 x 120 pixel image at the top of the sidebar. (I already run a strip of Google text ads at the bottom of the page, as I do here. I think too much advertising on a Web site is extremely obnoxious. But how much is too much when you have bills to pay?)

The Plugin

I won’t go into detail about my search for the plugin. It was neither long nor exciting. I wound up with AdRotator by Angsuman Chakraborty, which was really designed to work with Google AdSense and other prepacked blog advertising tools. But as I read the comments for the plugin’s description, I was assured that it would do what I needed to do.

But how do I use it? The User Manual was difficult to find. It wasn’t very user-friendly, either. (No offense to the plugin author. Frankly, I think that every programmer should team up with a tech writer to get documentation written. Programmers program. Writers write. Programmers don’t usually program and write — although an exception does come to mind.)

So I decided to write up a quick How To piece that would explain how to use AdRotator to do just what I wanted it to do. This isn’t AdRotator documentation. It only explains how to use the plugin for one particular task.

Also, these instructions don’t explain every single step in minute detail. If you want that kind of explanation, buy a Visual QuickStart Guide. Instead, these instruction assume you have already mastered the basics of using your image editing software, an FTP client, a text editor, and WordPress.

Create the Ads

First, use image editing software and your FTP program to create and upload the ad images.

  1. Decide on an ad size based on where you plan to place the ads. I used 170 wide by 120 tall so it would fit in the sidebar column of my theme (modified Connections).
  2. Use your favorite image editing software to create each image in the desired dimensions.
  3. Save the images as GIF, JPEG, or PNG format files with the appropriate file name extension.
  4. Use your favorite FTP client to upload the images to a folder within your WordPress wp-content folder. I created a folder called ads (real creative, huh?) and put them there. For obvious reasons, the folder’s permissions must be set so its contents are readable.
  5. Put away your image editing software; you’re done with it for now.

Install and Activate the Plugin

To use any WordPress plugin, you must download it, install it, and activate it.

  1. Download the plugin. This was pretty challenging, since I had a hard time finding a link to it. You can find a link on this page or simply click Download the plugin.
  2. Use your favorite FTP client to upload the AdRotator.php file to your plugins directory inside your wp-content directory.
  3. Go to the Plugins adminsitration panel in WordPress and activate the AdRotator plugin.

Create the Reference File

Now comes the part that seems to confuse most people (according to the comments). You need to create a plain text file that includes HTML for displaying the ad graphics with links to their URLs.

  1. Fire up your favorite text editor. Do not use a word processor like Microsoft Word! I use TextWrangler, which I can’t say enough nice things about.
  2. Create a new text file.
  3. For each ad/URL combination you want to include in the pool of ads, create a line in the text file that includes the following code:
    <a rel="external nofollow" href="http://advertiserurl.com" title='advertiser name or slogan'><img src='http://yoursite.com/wp-content/yourimagefolder/imagefile.jpg' border="0" /></a>
    Of course, you’ll substitute real URLs and text for what is shown above. A real example from my setup would be:
    <a rel="external nofollow" href="http://www.flyingmair.com" title='Helicopter Tours and Charters'><img src='http://www.wickenburg-az.com/wp-content/ads/flyingmair.jpg' border="0" /></a>
  4. Save the file with a Web-friendly name and the .txt file extension. In my example, I named it ads.txt (not very creative).
  5. Use your favorite FTP software to upload the file to the wp-content folder in your WordPress installation.

Reference the Ads

Now you need to reference the AdRotator plugin in the theme file in which you want the ad to appear. Normally, this will be header.php or footer.php (for banner ads) or sidebar.php (for ad boxes or towers).

  1. Open the theme file in which you want to reference the ad.
  2. Include the following code exactly where you want the ad to appear:
    <?php echo getad('adfilename'); ?>
    Of course, you’d replace adfilename with your file name excluding the .txt extension. So in my example, it would be:
    <?php echo getad('ads'); ?>
  3. Save the theme file you edited.

Check Your Work

That’s all there is to it. To check your work, display any blog page that uses the theme file you modified.

If you’re great at following instructions and I didn’t make any mistakes in the instructions here, it should work fine.

If you’re human (like I am), you’ll have to fix a number of tiny boo-boos you made along the way. The mistakes I made include wrong image URL (duh) and incorrect formatting (theme-dependent). I also made some ugly images the first time around and had to make new ones that looked better. I’m a writer, not an artist.

If you make some errors and your fixes don’t seem to be working, clear your browser’s cache. Then reload a page. It should be okay.

If you want to see how mine came out, visit http://www.wickenburg-az.com/.

Tips

A few tips for making advertisements less painful for site visitors:

  • Keep image file sizes small. I recommend less than 20K, but definitely less than 100K.
  • If the ad image is textual and you’re placing it on a colored or patterned background, consider saving the image as a GIF with transparency.
  • Animate GIFs look cool if properly done. Unfortunately, I can’t make one that isn’t terribly obnoxious.

And one tip for making advertisements more painful:

You can create multiple txt files, each with its own lists of images and links, and reference each one in a different place on your blog. This makes it possible to combine header, footer, and sidebar advertising on one site. Just don’t expect me to visit often; I really do hate ads.

Comments Off