Blogroll Links

My personal site, MariaLanger.com, doesn’t include a lot of links to blogs. One of the reasons for that is that I’m extremely particular about the sites I link to. I don’t link indiscriminately. I only link to sites I think are worth visiting.
And as we all know, there are just too many sites out there that just aren’t worth visiting.
The other reason I don’t have a lot of blog links is that I just don’t want my Home page sidebar to get too long. It’s already very long — if I wrote shorter entries, it would easily exceed the length of my entries as it often does on wickenburg-az.com.
So today, in preparation for supporting more blog links, I converted my WebLogs link category to a true blogroll, with a limited number of links. If I have more than the number of links I specified (5), WordPress will randomly choose which links to display each time the Home page is opened.
Setting this up in WordPress is easy. Here are the instructions for a server installation of WordPress:
- Log into WordPress and go to the Dashboard.
- Click the Links button to view the Manage Links administration panel.
- Click the Link Categories button to view the Link Categories Administration panel.
- Click the Edit button for the category you want to limit entries for. You’ll see the Edit Category administration panel for that category.
- In the Category Options area, enter a value in the Limit box and choose Random from the Sort Order drop-down list.

- Make other settings as desired in the administration panel.
- Click the Save Category Settings button. WordPress saves your settings and brings you back to the Link Categories administration panel.
From that point forward, the links in the category you modified will be limited to the number you specified, randomly selected and displayed. To display more or fewer links, just repeat these steps and change the value in the Limit box.
WordPress.com handles links and categories a bit differently. If you need instructions for doing this on a WordPress.com blog, use the Comments link for this post to ask and I’ll whip them up.
Technorati Tags: blog, blogroll, howto, links, WordPress
Listing Recent WordPress Posts

One of the features I included in my personal WordPress-based site (www.marialanger.com) is a listing of the 20 most recent posts. You can find this list in the sidebar of the Home page.
I created this list with the following code in the sidebar.php template file:
<?php wp_get_archives('type=postbypost&limit=20'); ?>
The type parameter tells WordPress to show individual posts. The limit parameter tells WordPress how many posts to display. You can set this number to anything you like.
I wanted to include this same feature on wickenburg-az.com, a site I maintain with information about the town I live in, Wickenburg, AZ. Unfortunately, that site makes full use of the Event Calendar plugin to display a list of upcoming events in the sidebar. Although the plugin is configured so events to not display on the Home page, it’s impossible to prevent recent event titles from being included when using the wp_get_archives tag — there’s no exclude parameter. And since clicking one of those titles would display a very boring two-line description of the event, I didn’t want those titles included in the list of recent posts.
What’s the solution? Well, I already had the Customizable Post Listings plugin installed on wickenburg-az.com. This plugin offers flexible ways to list posts in the sidebar. All I had to do was figure out the parameters to include all categories except the one set aside for Event Calendar.
I fiddled around with it a bit and came up with this:
<?php c2c_get_recent_posts (15,"<li>%post_URL%</li>",'1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 21 22 23 24','date','DESC'); ?>
The numbers in the code is a space-separated list of all the categories I wanted to include. I was lazy and just listed all category numbers between the first value (1) and the last (24) even though other values in between are skipped in my category list. Notice that 11 is missing. That’s the category number for the Upcoming Events category used by Event Calendar.
The result was the list I wanted. You can see it in the sidebar of the Home page at wickenburg-az.com.
Technorati Tags: howto, plugin, list, WordPress
WordPress as a CMS, Part 7

(If you’re just tuning in, this is the seventh installment of my series of articles about using WordPress as a CMS to build an informational Web site. Throughout this series, I’m talking about a specific site I developed: Flying M Air, a helicopter tour and charter company I operate when I’m not writing and tweaking my Web sites.)
I decided early on that I wanted my site to have a static home page that provided basic information about my company. Visitors could then use the links along the top of the page to view more information in other static pages or the links in the right column to learn more about specific tours and other services.
The Andreas theme I’d modified included page links along the top of the page. As I mentioned in Part 3 of this series, I created the pages and used the Page Order option to assign numbers to the pages that would determine their order. The theme automatically listed the pages by name as a row of buttons at the bottom of the header, using the following code:
<?php wp_list_pages('sort_column=menu_order&title_li='); ?>
Remember, the CSS code in style.css is what determines the appearance of the links on the site.
I created a home page, gave it a title of Home, and assigned a Page Order value of 0. That put it at the beginning of the list, right where a Home page button should appear. My Home page included random images (covered in Part 5 of this series) and text with links.
Now I needed to make that page be the page that appeared automatically when someone went to the default page of the root directory — in other words, www.flyingmair.com. I used the Static Front Page plugin by Denis de Barnardy. Miraz covered this plugin in our WordPress book, so I don’t want to go into a lot of detail about it here. I simply installed and activated the plugin, then confirmed that the Post Slug for the Home page was home. My Home page was the static Home page.
This may have satisfied a lot of people, but not me. The problem was, the page title (Home) appeared at the top of the Home page. I didn’t want it to appear at all. So I had one more thing to do.
Like all other Pages on a WordPress-based site, my Home page was displayed with the page.php file. I opened the file and inserted some conditional code (shown in bold type) around the instruction to display the title near the beginning of The Loop:
<strong><?php if (is_home()) { ?><?php } else { ?></strong><h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a> <?php edit_post_link('<img src="'.get_bloginfo(template_directory).'/images/pencil.png" alt="Edit Link" />','<span class="editlink">','</span>'); ?></h2><strong><?php } ?></strong>
Here’s how it works.
<?php if (is_home()) { ?>says that if this is the home Page, display what comes next. But that’s followed immediately by<?php } else { ?>, so nothing is displayed.<?php } else { ?>says that if this is any other Page, display what comes next. That’s the title as a H2 heading and link, as well as the icon I’m using for displaying an Edit link.<?php } ?>says to stop acting on the is_home conditional statement; the rest of the content should appear for all Pages.
The result: for any Page except the Home Page, the Page title appears at the top of the page.
I think that just about covers all of the special features I included in Flying M Air’s new WordPress-based Web site. Did I leave something out? Use the Comments link if you think there’s another topic I could cover in this series. Otherwise, I’ll call it quits for now.
But don’t worry; there are plenty of other WordPress-related tips and topics I can share. Keep checking in for more.
And now, can I interest anyone in a helicopter tour?
Technorati Tags: CMS, homepage, howto, plugin, website, WordPress
WordPress as a CMS, Part 6

(If you’re just tuning in, this is the sixth installment of my series of articles about using WordPress as a CMS to build an informational Web site. Throughout this series, I’m talking about a specific site I developed: Flying M Air, a helicopter tour and charter company I operate when I’m not writing and tweaking my Web sites.)
Because Flying M Air’s Web site was designed to be a sort of “online brochure” for my company’s services, I wanted the site’s visitors to be able to print information right from the site’s pages. Unfortunately, printing a WordPress blog page doesn’t seem to come out as pretty as it does on the site. Try it for yourself and see.
Although I could create PDF brochures for every tour and charter, it would be a royal pain in the you-know-what to recreate these documents every time I had a price change. To make matters worse, there was no way to force visitors to download the nicely formatted brochures instead of simply using their browser’s Print command to print what they saw in the browser window.
Clearly, I needed a better solution.
As usual, a plugin already existed to do the job: WP-Print by GaMerZ (AKA, Lester Chan). This plugin enables you to include a Print link or icon within The Loop for each post. When a user clicks the link or icon, the plugin generates a printer friendly page.
WP-Print is pretty easy to use. Just drop the plugin’s print folder into your plugins folder, go into the Plugins Management Administration Panel, and activate the WP-Print plugin.
Next, configure the plugin in the Print Options administration panel (Options > Print). You use the drop-down lists to indicate whether you want the user to be able to print comments, links, and/or images. I turned off images because they looked ugly with the yellow border around them. Click Update Options. You’re almost done.
Open the template file that includes The Loop and insert the following code where you want the Print link to appear:
<?php if(function_exists('wp_print')) { print_link(); } ?>
If you prefer a print icon like I have, no problem. Use this code instead:
<?php if(function_exists('wp_print')) { print_link_image(); } ?>
A word here about the Print icon that comes with WP-Print. It assumes you have a white background. I don’t. So I had to create my own little print icon. (I did the same for the e-mail icon, which I discuss later.) If you have to go this route, make it roughly the same size and give it the same name as the Print icon that comes with WP-Print and stick it in plugins/print/images/ to replace the existing icon.
If your theme uses The Loop in more than one place, you need to insert this code wherever you want the Print link or button to appear. For example, in my theme (Andreas), I had to insert it in index.php, archive.php, and single.php. I could have stuck it in page.php, too, but I didn’t need to, for reasons I’ll discuss in another installment of this series. In my MariaLanger.com site, which uses the Exquisite theme, I just had to stick it in the post.php file, which is called by all other files that need to display posts. A much nicer solution, if you ask me.
While I was adding plugins and code, I figured I may as well add an e-mail feature. GaMerZ has one of those, too: WP-Email. This plugin enables you to put an E-mail link or button in The Loop for each post. Clicking the link or button displays a form the visitor can use to e-mail the post’s contents to someone else — or himself.
As you might expect, the plugin installs the same way. Put the email folder in the plugins folder and activate the plugin in the Plugin Management administration panel.
Configure the plugin in the E-Mail Options window (E-mail > E-Mail Options). I won’t show them here because they’re too big to display on this page, but they’re pretty self-explanitory. You can get more information in the documentation. Just make sure you select PHP for the Method Used To Send E-Mail if you’re not using an SMTP server.
Of course, when I installed it, I skipped the configuration step, which caused me to do a whole bunch of other work…more on that in a moment.
Now open the template file that includes The Loop and insert the following code where you want the E-mail link to appear:
<?php if(function_exists('wp-email')) { e-mail_link(); } ?>
If you prefer a e-mail icon like I have, no problem. Use this code instead:
<?php if(function_exists('wp-email')) { email_link_image(); } ?>
Remember, I modified the e-mail icon so it would have that silly yellow background that appears on my site.
Now here’s where I screwed up — and only because I didn’t follow the instructions. Went onto the site and clicked the E-mail button for a post. A form like the one shown here appeared. The only problem was, there was no image in the Image Verification area. Why? Because the version of PHP I was using didn’t support captcha.
If I’d followed the instructions, I would have seen that that feature could be disabled. But I didn’t see the configuration options at all. So I did things the hard way. I upgraded PHP. And let me tell you, it was a scary thing to do. I actually lost all my blogs for about 10 minutes. Then I figured out how to get them back and everything is working fine. As an added bonus, I can now use the captcha feature in Spam Karma, which has cut my comment moderation work down to zilch.
Of course, I soon realized that I could only send one message every few minutes, which made testing tough. I found the configuration options and after slapping myself on the side of the head, adjusted the settings to give the new feature a good testing.
The moral of this story is RTFM — read the FABULOUS manual. (Gotta keep this site PG rated.)
While I’m discussing The Loop (kind of), I want to mention that I disabled the display of comments (and even comments links) in the Loop. I did this by commenting out the php comments_popup_link tag. I could have deleted it, but I was worried that I might need it someday and not be able to enter it back correctly. I already disabled comments and trackbacks in all posts and pages by setting defaults (as we discuss in our WordPress book).
Why did I do this? Remember, this blog is being used as a CMS. Although I could have left posts open for comments, I didn’t want to deal with Comment spam or have site visitors ask questions using the Comments feature. Visitors on the site are able to contact me using a contact form — that’s something we cover in our book so I won’t be discussing it in detail in this series.
In the next installment of this series, I’ll tell you about the site’s static Home page and the trick I used to get it to appear without a heading. Tune in next week!
Copy links from a server install to a WordPress.com blog

I’ve set up a new blog at WordPress.com for some work I want to do. Although I’m not actively using it until I get a little deeper into my project I wanted to add some links to the Blogroll there. As I already have some 40 links in my Link manager at Tikouka it seemed it would make sense to simply export those and import them into the WordPress.com blog.
That should be a simple task, expecially since WP.com blogs have a section in the Manage Blogroll section of the Dashboard to Import Links (as an OPML file).
The problem I had though, was to export the OPML file from my blog. After hunting all over the Dashboard I just couldn’t see how to do it. That drove me to search the Support forums. So, now that I have the solution, I thought I could save readers here some time.
There is nothing to click on in your server-installed WordPress blog to export links as an OPML file. Instead what you do is to call up the OPML file in your browser, like this: http://example.com/blog/wp-links-opml.php.
So, to import links from a server-installed WordPress blog into a WordPress.com blog you do this:
- Log in to your WordPress.com blog and go to Dashboard > Blogroll > Import Links.
- In the section labelled
Specify an OPML URL:enter the address of your blog, followed by/wp-links-opml.php. It should look like this:http://example.com/blog/wp-links-opml.php. - Click the button labelled
Import OPML file ». - Go to Dashboard > Blogroll > Manage Blogroll to edit the links as you see fit — change categories, delete, amend, and so on.
Note: I found my categories had been imported as links too, so needed to delete them.
It’s all astonishingly easy, once you know how.
Updating a WordPress 2 Server Installation to Version 2.0.4

I just finished updating my four locally-hosted WordPress-based sites, MariaLanger.com, wickenburg-az.com, wpvqs.com, and FlyingMAir.com. Now all of these sites are running on the same version of WordPress: 2.0.4.
The updates from versions 2.0.1 and higher were very easy to do. Here’s how I handled it:
- Back up your WordPress database. (Just in case.)
- Download the new version of WordPress from the WordPress.org WordPress 2.0.4 page.
- Uncompress the archive you downloaded.
- Remove and discard the
wp-contentfolder from the downloadedwordpressfolder. This prevents you from accidently overwriting customized content in that folder, including plugins, customized themes, and images (if you store them in thewp-contentfolder like I do). - Make a backup copy of your WordPress root directory. (Just in case.)
- Copy all remaining files to the WordPress root directory on your server. Allow the new files and folders to overwrite the existing ones.
- Display the home page for your blog. Does it look right? Check a bunch of links to make sure it displays correctly.
- Display the Dashboard for your site. If you see a message telling you that your Database requires updating, follow the links that appear to update the database and complete the installation. (I only needed to do this on one of my blogs that was running WordPress 2.0.1.)
- If everything continues to work well for a few days, discard the backup copy of your WordPress root directory and database. (Continue backing up both on a regular basis.)
Technorati Tags: howto, update, WordPress