Home About the Book About the Authors Handy Links

It’s the browser!

Miraz.

It’s particularly frustrating to find that I’ve spent several hours today searching forums and FAQs, checking documentation and trying a million variations of instructions only to find that Safari doesn’t work correctly when adding files, such as MP3 files, to a WordPress post. Firefox gets it right.

Here’s what happens: you upload an MP3 with the wee Upload form on a WordPress Post editing page. You click on the link for the uploaded file and a kind of overlay appears with some options. You can link to the file or link to a page. If you choose Link to File Safari creates a link like this: <a href="tui.mp3">, whereas Firefox correctly creates a link like this: <a href="http://example.com/blog/wp-content/uploads/2006/04/tui.mp3">

Because Safari inserts a relative link, the link just doesn’t work when you view the post in a browser — it’s relative to the wrong thing and the file just isn’t where the coding says it is. Moreover, it doesn’t work as a podcast because the RSS feed requires the full path for the enclosure.

Firefox inserts the full path, which is, moreover, correct. Visitors to the web page can click the link to listen to the file and the MP3 correctly downloads to a podcatcher as an enclosure.

Who would have thought?

I’ve just sent a bug report to Apple: Safari menu > Report bugs to Apple…

Comments Off

How to Create a Gravitar

Maria.

If you read a lot of blogs, you’re probably already familiar with gravatars — custom images that represent certain commenters. These images are a kind of personal logo that identifies them and says something about their personality.

Here’s how gravatars work. A commenter creates an image suitable for a gravatar and uploads it to his account on gravatar.com. The gravatar is rated using pretty much the same ratings as the movie industry: G, PG, R, and X. These ratings are used by bloggers to set limits on the kinds of gravatars that appear on their sites — a gravatar with a G rating will appear everywhere while a gravatar with an X rating may not appear on many blogs at all.

Meanwhile, a blogger (like me) sets up her blog to enable it for gravatars. Then, when a commenter submits a comment, the blog’s gravatar plugin takes the commenter’s e-mail address (submitted in the comment form) and attempts to find a match at gravatar.com. If it finds a match, it displays the corresponding image. (The e-mail address is not used anywhere in the underlying page code.) If there’s no image on file, the plugin either displays nothing or displays a default image chosen by the blogger.

If you frequently participate in blogs by leaving comments for blog posts, you should consider creating a gravatar. Its easy and its free. Here’s how.

  1. Sign UpGo to gravatar.com’s Signup Page.
  2. Enter your e-mail address and chosen password (twice) in the boxes and click Submit. A message appears, telling you that an e-mail message has been sent to your account.
  3. Check your e-mail. You should find a message from Gravatar with the subject “Gravatar Account Request.”
  4. Click the long link in the e-mail message. Your browser opens and displays a message confirming that you have successfully activated your account.
  5. Use your favorite graphics application to create an image suitable for use as a gravatar. For best results, it should be 80×80 pixels in size and not include a border. (Keep in mind that it might be displayed at smaller sizes.)
  6. Save the image as a JPG, GIF, or PNG image with an Internet-friendly name (no spaces or weird characters).
  7. Use your Web browser to open your Admin page on gravatar.com.
  8. If necessary, log into your account.
  9. UploadIn the Current Gravatar area, click the Browse button and use the dialog that appears to locate, select, and open the image you created for your gravatar.
  10. Click the Upload button. The file is uploaded and appears in the Pending Gravatar area.
  11. Wait for the gravatar to be rated and approved. This is the hard part. It took about 6 days for my gravatar to be approved. Hopefully, the folks at gravatar.com have gotten more volunteers and can handle the rush of new accounts.

GravatarWhen your gravatar has been rated, you’ll get an e-mail message. Then, when you log into your gravatar.com Admin page, you’ll see your image and rating. From that point on, your gravatar should appear whenever you post a comment to a gravatar-enabled blog — like this one.

Now I know that I said creating a gravatar was free, but if you like this feature and think the folks at gravatar.com are doing a good job making blogging a bit more interesting and personalized, visit the gravatar.com Donations page. They ask for $10, but I’m sure they’d accept any amount. They run a server there and currently do not support it with advertising, so donations would be greatly appreciated.

Do you have a gravatar now? Show it off by entering a brief comment on this post.

Comments Off

How to Create an RSS Feed Page

Maria.

WordPress has a powerful and flexible Pages feature that enables you to create Web pages that are part of your blog yet exist outside the blog chronology. You can find examples of the Pages feature on this site by clicking the links at the very top of the page; all of them except FAQ point to WordPress Pages on this site.

Note that I’m using an uppercase P when discussing this Pages feature. That’s so you don’t get confused between the generic use of page (as in Web page) and WordPress Page feature Page.

My personal site has a bunch of categories that can be broken down into two groups: book support categories and Maria’s WebLog categories. You can see them listed in their groups in the sidebar, with a bunch of links between them.

Although I’d like to believe that Maria’s WebLog is so incredibly fascinating that most people come here just to read it, I know that’s not true. Many people come here to get additional information and support for my books. There are a bunch of these books (61 or 62 at last count) and a handful still in print at any time. This site’s Book Support categories provide support for those books.

Why Bother with a Custom Page?

On my old support site (www.langerbooks.com), each book had its own RSS feed. I didn’t realize it until recently, but many readers were using that feed to keep apprised of new content via RSS feed reader software. As I have stated elsewhere, although I know what a newsreader is for, I don’t personally use one on a regular basis. So it wasn’t until I realized that people were looking for those old feeds that I decided to provide new feeds to replace them.

There was an easy way to do this: simply include the feed=RSS parameter in the wp_list_cats template tag I use in the sidebar. So, for example, my current use of this tag:

< ?php wp_list_cats('sort_column=name'); ?>

would be changed to:

< ?php wp_list_cats('sort_column=name&feed=RSS'); ?>

If you’ve got sharp eyes and know WordPress, you may realize that something’s missing from that tag: the exclude parameter that enables me to break your category list into two groups without using parent and child categories. I’ll cover that in a future article.

Using that second bit of code would display (RSS) after each category name in the sidebar. RSS would be a link to the RSS feed for that category.

The trouble is, I didn’t like the way it looked. After all, who really wants to see (RSS) after every single category name in the list? It looks goofy. I didn’t like it, so I didn’t want to do it that way.

Instead, I decided to tap into the Pages feature and create my own custom Page template for listing RSS feeds.

Creating the File

To do this, start with one of the existing Pages templates. The one I picked was archives.php, which can be found with your other theme files in its theme folder.

If your theme does not include archives.php (not to be confused with archive.php), you’ll have a bit more work to do. You’ll have to get the archives.php file from the Default theme and the index.php file from your chosen theme and create a sort of hybrid with header information from archives.php inserted in index.php that has The Loop removed. If you know what I’m talking about, go for it. If you don’t, stop reading and wait for a future article about creating a Pages template when one doesn’t exist for your theme. (You may have to wait a while; comments requesting such an article might help push me to write it.)

Now with the achives.php file open in your favorite text editor (hopefully something that’s a real text editor and not a word processor), start by saving the file with the name rssfeeds.php (or something like that) in your theme’s folder — that’s the folder where your other theme files reside. Now edit the contents of the file as follows:

  1. Replace Template Name: Archives with Template Name: RSS Feeds
  2. Delete everything that’s in the “content” of the page. In my theme, for example, that’s everything between <div id="content"> and </div>, not including those two lines.
  3. Insert (where the lines were deleted) the codes to display the category names with the links. That can be something as simple as what’s noted above: < ?php wp_list_cats('sort_column=name&feed=RSS'); ?>. Or it can be kinda fancy, like what I’ve got in my version of the file:

    <h1>RSS Feed Links</h1>
    <p>Click the icon or use the RSS link to subscribe to an RSS feed for the entire site or a specific site topic.</p>
    <h2>Entire Site</h2>
    <ul>
    <li><a href="http://feeds.feedburner.com/marialanger" title="Subscribe to Maria's WebLog" rel="alternate" type="application/rss+xml"><img src="http://www.feedburner.com/fb/images/pub/feed-icon16×16.png" alt="" style="border:0"/></a></li>
    <li><a href="http://add.my.yahoo.com/rss?url=http://feeds.feedburner.com/marialanger" title="Maria's WebLog"><img src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif" alt="" style="border:0"/></a></li>
    <li><a href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=
    http://feeds.feedburner.com/marialanger" title="Maria's WebLog"><img src="http://www.newsgator.com/images/ngsub1.gif" alt="Subscribe in NewsGator Online" style="border:0"/></a></li>
    <li><a href="http://fusion.google.com/add?feedurl=http://feeds.feedburner.com/marialanger">
    <img src="http://buttons.googlesyndication.com/fusion/add.gif" width="104" height="17" style="border:0" title="Maria's WebLog" alt="Add to Google"/></a></li>
    <li><a href="http://www.bloglines.com/sub/http://feeds.feedburner.com/marialanger" title="Maria's WebLog" type="application/rss+xml"><img src="http://www.bloglines.com/images/sub_modern1.gif" alt="Subscribe in Bloglines" style="border:0"/></a></li>
    <li><a href="http://feeds.my.aol.com/add.jsp?url=http://feeds.feedburner.com/marialanger">
    <img src="http://myfeeds.aolcdn.com/vis/myaol_cta1.gif" title="Maria's WebLog" alt="Add to My AOL" style="border:0"/></a></li>
    </ul>
    <table width="100%">
    <tr>
    <td width="50%" valign="top">
    <!-- BLOG CATEGORIES -->
    <h2>Maria's WebLog</h2>
    <ul><?php wp_list_cats('exclude=1,24,25,26,27,29,30,31,32&sort_column=name&feed=RSS'); ?></ul>
    </td>
    <td width="50%" valign="top">
    <!-- BOOK SUPPORT CATEGORIES -->
    <h2>Book Support</h2>
    <ul><?php wp_list_cats('exclude=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,33&
    sort_column=name&feed=RSS'); ?></ul>
    </td>
    </tr>
    </table>

  4. Save the file’s changes.

Creating the Page

Once the file has been created and saved to the appropriate folder in your themes folder, you’re all ready to use it.

  1. Log into your WordPress blog and use the navigation at the top of the page to get to the Write Pages administration panel.
  2. In the right column, choose RSS Feeds from the Page Template drop-down list.
  3. Click Publish beneath the Page Content box.

Sure, you can enter a page title and content in the boxes. But they’ll be completely ignored so you’ll be wasting your time. Only the tags you included in the template will appear in the page.

Using the Page

The last step is to link the page to your site. If you already use the get_links or wp_get_links tag in your sidebar, you’re done; the page will appear with the other pages that are listed. But if you don’t (I don’t) you’ll have to modify the sidebar.php or, in my case, the header.php file to add the link. I call the link RSS and you can see it at the top of every page.

That’s All There Is To It

Of course, if you’re like me you won’t be happy with the first version of the Page. But fixing it is easy. Just use your text editor to modify the rssfeeds.php file you created. You can reload the Page on your blog to see the results of your changes. No need to edit the Page. After all, there’s nothing in the Page, is there?

What do you think of all this? Use the Comments link to let me know. You can also use the Comments link for this post to submit questions about it; please don’t ask questions about topics not covered in this article.

For more great information about going beyond the basics with WordPress, be sure to visit the WordPress Codex and the WordPress Support Forums.

Comments Off

Another WordPress Plugin

Maria.

As I wonder whether the trackback/pingback problems on my site are related to an overabundance of installed WordPress plugins, I couldn’t resist installing another one: Clean Archives. This nifty one-trick pony by Shawn Grimes, based on code originally by Sebastian Schmieg, enables you to create a list of archives by date — not just month.

The plugin is easy to install and activate. Just drop it in the plugins folder and use the Plugins administration panel to activate it. Then just add a bit of code wherever you want the archive list to appear. The Read Me file explains all.

On my blog, I added it to the archives.php file, which is the template for an Archives Page. You can see it in action here. I got a bit fancy here by creating a two-column table with the first column for a standard archive list by month and category and the second column for the Clean Archives list. Because this blog has so many entries (over 400 these days), that middle column is pretty long and takes quite a while to load.

I also tweaked the plugin to remove the comment count for each post. Most of my posts don’t have any comments (shy readers?), so there were too many (0)s for my liking. I commented out Shawn’s code so I can add it back in the future.

Just another WordPress blog tweak.

Comments Off