Random Tips for Wordpress Beginners

Recently I have been helping good friend Ted Sanft with both his personal blog and his hockey team’s site. In the case of the hockey site specifically I helped Ted get setup and introduced to the Wordpress platform in addition to providing the design. Since then he has seemingly fallen in love with Wordpress. Along the way he has had several good questions that I think would be helpful for anyone to hear that is getting started with WP, and that’s what I’m presenting here.

Note: This article assumes you have at least a small amount of knowledge of css/xhtml, etc., and can follow copy/paste php instructions.

As soon as your site goes live, change your permalink structure.

Permalinks are how your URLs are presented for posts, categories, pages, and so forth. Out of the box, the urls Wordpress provides are pretty ugly, for example instead of the url you currently see in the url bar, if permalinks were set to default here it would look like this:

http://muelface.com/?p=105

Using a permalink structure that actually corresponds with the content on the page being viewed is helpful for search engines, something that is especially important when you are starting a new blog and praying for traffic. Although I have often read that using something that ends in “.html” is best, in my personal experience ANY permalink structure that presents the title of the post (and possibly the date if you are a news-related blog) is just as good.

To change your permalink structure click on Settings at the top right of the Wordpress admin panel, then select Permalinks. Change the permalink structure to something other than default, then save. If you want, you can write your own custom structure, find out more here. Note that your server will have to have mod_rewrite enabled for this to work, and your .htaccess file needs to be writable. This isn’t a problem in most cases.

If at all possible, DON’T use the visual editor for posts/pages.

I can’t count the number of times a client and I have been left scratching our heads as to why styling written into a post wasn’t working. Most of the time it had to do with the fact that the visual editor was enabled. Although this editor is great if you have absolutely no clue when it comes to css/html, it often mangles start and end tags, and especially throws in “p” tags everywhere. To turn this off and keep yourself out of trouble, click on Users at the top right of the admin panel, select Your Profile, and then uncheck the “Use the visual editor when writing.”

A few more tips for simple in-post styling:

  • Create left and right float classes in your stylesheet to quickly allow for aligning things, and a clear class to make sure they are applied correctly.
    .left {
    float: left;
    }
    .right {
     float: right;
    }
    .clear {
     clear: both;
    }

    Then it is easy to apply class=”right” etc. to any element to get it where you want it in a post or page.

  • Create various headings to use in posts/pages to delineate “sections.” For example:
    h3 {
    font-size: 18px;
    }
    h4 {
     font-size: 16px;
    }

    Then you can use h3 tags for “sections” and h4 tags for “subsections.”

Don’t worry, you can display “just those posts” on a certain page.

One of the template tags I find myself using most often is the ?php query_posts tag. This tag allows you to create page templates that will show basically any combination of posts you want. Want just these 2 categories but not the other? No problem. Want to show posts with only a certain set of tags? Easy. This tag is one of the most powerful I have found in terms of extending Wordpress beyond the built-in post/page structure. Here’s a simple example of how to create a page that will display posts from a certain category tagged with 2 certain things.

  1. Duplicate your index.php file from your current theme, name it custom_query_page.php
  2. At the top of this new file, insert the following:
    <?php
    /*
    Template Name: Custom Query Page
    */
    ?>
  3. In this new file, find the following line:
    <?php if (have_posts()) : ?>

    and insert the following above it:

    <?php query_posts('cat=3&tag=tag1,tag2'); ?>

    Of course, replace the “3″ with the category ID you want to pull from and the tags with the tags you want to display.

  4. Upload your new file to your theme directory.
  5. Create a new page, give it a title, and select the Custom Query Page template below the text entry area. No need to enter anything in the text entry area.

That’s it, you’re done. You now have a new single page that will show posts just as your home page does, except it will only pull posts with certain tags within a certain category.

Hopefully this will provide useful. Wordpress is a great tool, and my preferred platform for CMS development that requires a minimum of custom code. If you still have questions, there is always the Wordpress Codex and Wordpress Community.

2 Responses to “Random Tips for Wordpress Beginners”

  1. Informative post. I have a long way to go with this…I still have trouble linking all my e-mail addresses to the Apple Mail program!

    September 26th, 2008 at 8:40 am
  2. Gmail FTW! Seriously though, I’ll be posting more tips here as time goes on, and hopefully once you really dive into WP you’ll learn by the good ole “sink or swim” method.

    September 26th, 2008 at 8:42 am
Leave your comment!
Valid XHTML 1.0 Transitional