Matt’s Custom Query String Plugin

Every week I write a free Tip about using Macintosh computers. With five years of Tips in the archive I often want to refer back to build on a previous tip. I can do that with a link to one tip, but for some topics it’s more appropriate to link to a search result.
The problem may arise though that the search finds a dozen relevant posts, but my blog is set to display only a few posts per page. This setting carries through to search results, and visitors have to click on the “Previous posts” or “Next posts” link after every few results. That’s very tedious.
Enter Matt’s Custom Query String Plugin:
This plugin will allow you to set the number posts to show for all the different “query views” and each your categories in WordPress. You can choose how many posts or days, and what to order them by, for any of the queries and/or categories. All this easily set from an options page within the admin area.
Matt gives clear instructions on his page about how to install the plugin, and even has a support forum for the confused. The particular setting I needed was easy: choose the “is_search” condition and set it to -1 posts per page. -1 shows all results from a search.
WordPress as a CMS, Part 4

(If you’re just tuning in, this is the fourth 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.)
Before I begin this installment, I want to take a moment to remind readers that although the topics I’m covering in this series are for Intermediate to Advanced WordPress users, WordPress 2: Visual QuickStart Guide, which I co-authored with Miraz Jordan, is for Beginning to Intermediate users. The book uses an extremely structured step-by-step approach, with lots of referenced screenshots to guide readers through the completion of hundreds of tasks. (Click here to download a PDF file (2.3 MB) of part of Chapter 3.) This article series uses a more conversational narrative tone and assumes that readers already know the basics.
My point? Don’t shy away from the book if the articles in this series have been too difficult for you to follow. The book will likely provide you with the basic information you need to get started with WordPress and move on to the next step. After working with WordPress (and hopefully, the book) for a while, you’ll be ready to articles like the ones in this series.
Now on to business.
One of the drawbacks of using a blog format for sharing information that isn’t necessarily date-specific is that entries are presented in reverse chronological order. To get around that, I had to tweak the dates of the posts so the ones I wanted to appear at the bottom of a category page would have earlier dates than the ones at the top.
The other related problem is that not everyone likes to scroll down a page to see all of its contents. So, for example, if I had six tours in my Wickenburg Tours category, there was a good chance that a site visitor would never scroll down the page to see them all.
To resolve this potential problem, I decided that I wanted a list of all tours to appear near the top of the sidebar. But only the tours for the category currently being viewed. So while viewing the Wickenburg Tours category, I wanted just the entries for that category’s tours to be listed.
To do this, I had to insert some conditional statements into the sidebar.php template file. Here’s an example:
<?php if ( in_category('2') ) : ?>
<li>
<h2>All Wickenburg Tours</h2>
<ul>
<?php
$posts = get_posts('numberposts=10&category=2&orderby=post_title&order=ASC');
foreach($posts as $post) :
?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endforeach; ?>
</ul>
</li>
<?php endif ; ?>
What this basically says is that if WordPress is displaying the Category 2 page, it should display a heading of “All Wickenburg Tours” followed by an unordered list of up to 10 post titles (with links) for category 2 in alphabetical order.
(Keep in mind that this code includes a lot of extra tags required by my theme for formatting lists in the sidebar; these tags must be stripped out or modified for other themes.)
I then created the same bit of code for each category that listed my tours and inserted it into the sidebar.php file, right after the search form.
I went a step further with this, however. I also wanted the appropriate list of posts to appear if a visitor was looking at a post on its own (single) page. So I inserted <?php if ( is_single() ) : ?> before the first conditional tag and <?php endif ; ?> after the last one. That put all of the tags within a conditional statement that ensured it would be properly executed on a single page, too.
The best way to see what I’m talking about is to just visit the site and experiment with its category and post links.
In the next installment of this series, I’ll explain how I got the images to automatically change in the left sidebar and on many of the pages.
Check your plugins when you upgrade WordPress

When you upgrade WordPress to the latest version (2.0.4 as of today), it’s a good opportunity to check and maybe update your plugins too. I found that TiKouka was running a slightly outdated version of Spam Karma so went and grabbed the latest version.
Go to the Dashboard and click on the Plugins link. Run your eye down the leftmost column, titled Plugin. Click on any link in that column to visit the plugin’s home page.
if you find a plugin useful, remember that the author probably welcomes a donation. With spammers battering at my blogs this week Dr Dave’s Spam Karma and Michael Hampton’s Bad Behavior are invaluable for me, as you can see from these recent Spam Karma reports for TiKouka:
- Sunday: There have been 4155 comment spams caught since the last digest report 1 day ago.
- Saturday: There have been 12170 comment spams caught since the last digest report 1 day ago.
- Friday: There have been 1034 comment spams caught since the last digest report 1 day ago.
And that’s just one blog! I’d turned off Bad Behaviour for a couple of days and that almost certainly allowed more of the bad guys through. Keeping these plugins updated helps my blog run more easily, with less effort from me.
WordPress 2.0.4 now available

Matt reports on the Development Blog:
WordPress 2.0.4, the latest stable release in our Duke series, is available for immediate download. This release contains several important security fixes, so it’s highly recommended for all users. We’ve also rolled in a number of bug fixes (over 50!), so it’s a pretty solid release across the board.
Maria and I both have several blogs to upgrade, so we’ll be back in a while…
Security Alert!

Dr Dave, developer of the must-have spam prevention tool, Spam Karma, sent out the following alert message to all Spam Karma users as an announcement in the Spam Karma administration panel:
MAJOR SECURITY ANNOUNCEMENT
Affecting all WP users (this is not specifically a Spam Karma problem). Please immediately disable ‘guest user registration’ on your blog if it’s enabled and advise all your friends to do so (details here). I cannot give too much technical details as it would further endanger vulnerable Wordpress users, but trust me this is not a joke.
What Dr Dave means is to follow these instructions:
- Log in to your WordPress blog and display the Dashboard.
- Click Options to display the General Options administration panel.
- Turn OFF the Anyone can register check box under Membership.

- Click the Update Options button at the bottom of the window.
On his site, Dr Dave also recommends that if this option had been turned on, you should view your Users list and delete any user you’re not sure about.
Dr Dave did not provide any details for this security problem. He’s worried that it’ll spread the word about how a WordPress system might be compromised.
Our advice: just do it. I’m sure more details (and probably a fix) will come soon.
Sidebar Widgets

There is sometimes confusion over features available in wordpress.com blogs vs. those available only in WordPress server installations. Although we tried our best to point out each instance where an instruction only worked for one type of blog, we may have missed one or two spots or may not have been as clear as we should have.
Reader Ken writes:
On page 18 re: Sidebar Widgets you give a list of buttons to press to get to the sidebar configuration screens. Problem is that I can’t seem to find the Sidebar Widgets button under Themes under Dashboard!!? Can you check those directions and let me know how to get to widgets?
The Sidebar Widgets button appears when you click the Presentation button if you are accessing a wordpress.com blog.
To use Sidebar Widgets in a server installation of WordPress, you need to install the Widgets plugin, which is so new that we have not had a chance to look at it. I suspect, however, that the Widgets plugin won’t work with all themes, so if you do try it, be sure to read the documentation carefully.