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.

How to use WordPress as a CMS Part 1

Just a little semi-beginner information that assumes:

  1. That you know what I’m talking about.
  2. That you are considering using WP to build a website.
  3. That you are familiar with the process of building a website.
  4. That you know what a CMS is and why people need them.
  5. That you are familiar with using WordPress.

But I’m going to try to explain it from the approach of someone with a limited working knowledge of php and I am not going to write about the WordPress Loop that much because there are already many very good WP how-to’s about the Loop.
If you’re used to WordPress but haven’t ever considered it as a CMS,I don’t blame you.
The language in WordPress theme’s codes “bloginfo this and bloginfo that, and if have posts while have posts” can throw you off at first…

what if you aren’t interested in creating a blog site? & WP is intended to be a blogging tool so it makes sense that the language of the code relates to blogging.
Continue reading How to use WordPress as a CMS Part 1

I finally found a photogallery I like

lzenogo.png.
And someone created a plugin for it for WordPress so now all I have to do is load them up and sort my photos. If I like it and it doesn’t wreck my theme too much I will be very pleased.I’ve been looking and looking and hadn’t found anything I could tolerate.
It had to have an easy to integrate theme in css, not tables.
It had to be easy to use.
I didn’t want to use any flash or ajax or have to assign rel tags to every photo.
I was very demanding and lazy.
I wanted something right out of the box.
I am really tired of redoing tables based layouts in css and xhtml.
The reason I never bothered with Zen Photo before is that I associated it with Zen Cart.
Because ofthe name Zen.Isn’t that silly? As far as I can tell they aren’t related.
And while Zen Cart doesn’t take a genius to make look presentable it is beyond my patience to labor over something that large and unweildy just to have a gallery.I’d do it for a client but hell no, not for my own site.