Your WordPress theme code is out of date

Theme code not fit for WordPress 2.3.3 can be dangerous. I found this out the hard way.

Yes, it matters. You cannot simply upgrade the core files,you must also make sure tags and hooks in your theme are compatible as well. I’m afraid you are sort of on your own there,though.The WordPress Codex is not the most up to date batch of articles and it is from there that I have been gathering my little bits of theme info.

Which makes me wish there was a comprehensive list of tags and hooks and etc that have been definitively depreciated so that I can be sure not to use them ever again.Well of course they tell you what’s been out since 1.5 and 2.1 but not much else…
The best I could tell you is to grab a copy of an approved for 2.3.3 theme and explore its guts, comparing the code you tend to reuse with their’s and try to get up to date.
Or just keep triggering errors and wondering why, God, WHY?
I was able to find an answer in the WordPress forums despite the fact that it seem as though 98% of the questions go unresolved. But this is only because no one ever bothers to search the forum threads so the same questions get asked over and over and it tires the experts out to keep answering it.
I’m not absolutely sure that this is right but I’m pretty sure the theme code in the 2 default themes that come with every WordPress download are up to date. I hope so because I usually rely on Default for help.

Conflict with Next Gen Gallery and WP-shopping Cart

When I was setting up my friend’s new site I installed Next Gen Gallery.
Then she needed to be able to sell stuff so I installed WP Shopping Cart.
Then the madness began!
Thumbnails were doing cartwheels and somersaults or not opening at all.Or double images were appearing for each thumbnail.Was it a Poltergeist? A Gremlin? Nope: just 2 copies of scripts doing things together and doubling up everything! Not good.

Why was this happening?

Both plugins use thickbox.js,thickbox.css and lightbox.css.You only need one copy of each installed or you will experience odd performances of the lightbox window when clicking on a thumbnail image either on your shop or gallery pages.

My solution is probably not the best but it worked.
I went to wp-content/plugins and opened the wp-shoppingcart folder.I found thickbox js and css and also lightbox.css and just erased the code from all files,leaving the blank file in the folder.
I thought about deleting these files but then I decided to be on the relatively safe side I’d just leave them but empty.
I should say that separately both plugins work fine,at least when it comes to using the lightbox window).
Problem Resolved.
I should state just for the sake of the easily befuddled that if you do not have both plugins but are still experiencing trouble this solution will not work for you.This is just for trouble had when BOTH plugins are installed into one WP installation!

How to use WordPress as a CMS part 3

In the past 2 posts I covered the menu and how to set which page will be the home page.

And here is how to have a custom home page with dynamic content. A static page is not the best thing for a home page because it’s just kind of dull– a freshly updated and interesting home page is more exciting, better for SEO, better for site visitors. It’s the home page, after all. It’s usually the 1st thing people see when they land on your website.

I got the idea for this while working on an ecommerce website where we weren’t going to be showing the blog on the home page but still wanted to show some stuff from the blog. We created a What’s New , category, assigned posts to it and they showed on the home page. We didn’t end up using it but it was a bit of work to figure out so I wanted to pass it on.

Show 3 excerpts from a single category in a custom home page template:

[php]
<?php $more = 0; ?>

<?php query_posts(‘cat=2&showposts=3’); ?>

<?php if (have_posts()) : ?>

<?php while (have_posts()) : the_post(); ?>

<div class="post" id="post-<?php the_ID(); ?>">

<h2 class="post_title"><?php the_title(); ?></h2>

<div class="post_category">Posted in <?php the_category(‘, ‘) ?></div>

<div class="post_comments"><?php comments_popup_link(‘No comment’, ‘1 Comment’, ‘% Comments’); ?> <?php edit_post_link(‘Edit’, ”, ”); ?></div>

<div class="post_datetime"><?php the_time(‘F jS, Y’) ?> at <?php the_time(‘g:ia’); ?></div>

<?php if (is_search()) {

the_excerpt();

} else {

the_content(__(‘Read the rest of’) . "\"" . the_title(”, ”, false) . "\" &raquo;");

} ?>[/php]

Ok, if you copy and paste that you’ll break your page because the divs aren’t closed and neither is the Loop.
I’ll try to explain what each bit does.

[php]<?php $more = 0; ?>[/php]
makes sure the more tag can be used in the Page template, since the more tag is reserved for Posts.

[php]<?php query_posts(‘cat=2&showposts=3’); ?>[/php]
pulls the latest 3 posts from category ID 2

Some things may go awry:

Your client may forget which category is going to show on the home page.

That’s why it’s a really good idea to walk them through the dashboard and explain the whole category thing to them.

Also, name the category something like Home Page News so they will be more likely to recall this is the category for displaying post excerpts on the Home Page.

[php]<?php if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?>[/php]
good old Loop

[php]<?php if (is_search()) {

the_excerpt();

} else {

the_content(__(‘Read the rest of’) . "\"" . the_title(”, ”, false) . "\" &raquo;");

} ?>
[/php]
bit of code to show content as an excerpt if it’s a search.

relies on the person writing the posts remembering to put in the more link and choose the right category for the posts.

This template is only an example – you have to change the names of the divisions to match the names in your theme -so the stylesheet can work- and make sure they’re all closed. That means checking the header and footer, too. And you’ll want to change the category ID to one you want to show.

download template

How to use WordPress as a CMS Part 2

In “How to use WP as a CMS Part 1” I wrote about how to remove the double up effect of the menu/navigation when you make a static page and select it to be the front page of the website.

If you’re shopping for a CMS – not a blog system – you might think WordPress is not the right tool for the job because of the language used throughout the dashboard which is “Blog this and Blog that”. But you would be missing out on using an excellent platform that makes it easy to launch dynamic websites.

You should build sites that your clients can edit themselves. The site owner should not have to go to their host control panel or use a text editor and FTP–which might frighten the pants off of them. I call it code shock. Those unused to looking at code will be so scared of it that they might be too afraid to touch anything resulting in a static site that never gets updated because the owners were too afraid to update it.

You and I both think it’s easy to add text and images with a text editor and use FTP. But your client hasn’t been studying HTML in their free time and probably will not know how to use an FTP client.

So if you use WordPress to build their site they never have to look at code which means they will be 100% more likely to edit their own pages. And sites that get updated frequently keep everybody happy. The days of having to hire someone at 40 bucks an hour to edit 2 lines of your website are OVER. Thank God.

So let’s get started!

In order to make a static home page and use the Loop you open a new document with Notepad, Crimson Editor or Textwrangler and put this at the top of it:

[php]
<?php
/*
Template Name: Home Page
*/?>[/php]

Copy the code in page.php or index.php or archives.php and paste it after that and save the new file as as homepage.php.

Then use FTP to upload this file to your theme’s folder in /wp-content/themes/your theme.

Go to Manage>Pages>Home and scroll down to the select box on the left:

Default Template is selected by default, but now the template for the home page should also be there ready to get selected. I don’t have a template for my home page so the drop down shows my other templates. But you get the idea.

So now all that’s left to do is make sure the structure HTML of the document is laid out in the way you want the home page to look. With a few simple tweaks to the CSS it ought to be ready to go. When it is ready go to Settings>>Reading – Front Page Displays: click on the radio button for a Static Page then choose Home from the drop down. You can then go to Pages>>Add New and create a new Page to be your Blog Page. Then go back to Reading and choose that page to be the blog.

I’ve said before that you don’t need a blog at all but I’ve since changed my mind because there are so many things you can do with Posts and Categories and there is no reason the results have to look bloggish or blog-y.

So there it is. WordPress makes it easy for us web designers to hand off websites to clients that they can manage themselves. The more I use it to build different kinds of sites the more WordPress proves to be a versatile Publishing Tool. Don’t let the blog-centric language scare you.

In my next post I’ll show how you can add to the code in homepage.php to use a custom query.