Ultimate Guide to the WordPress Loop

One of my favorite parts about using WordPress for my blogs is getting to work with PHP code, which I find to be much easier to write/hack.   For those that are shy around code, it really isn’t that difficult to get ahold of the basics of PHP, so WordPress is the right place for you. 

One great area to start is learning how the WordPress loop works.  This is a basic function of blogging used to display the most recent X number of posts on your blog’s homepage (for traditional blogs).   Rather than go into to much detail here, I’d like to point you towards a new post by Themelab which is designed to be the Utlimate Guide to the WordPress loop

This post definitely lives up to its name and goes beyond just showing you how to do something.  It actually explains how and why it works, and includes screenshots with many of the examples.   If you have any interest in learning about the WordPress loop you may want to read through this post and/or bookmark it for future reference. 

  • Leave a Comment
  • How To: Display A WordPress Tag Cloud On Your Blog

    Depending on how your WordPress blog is set up, you may have an interest in displaying your WordPress tags for your readers to dig through in a nice looking cloud format. This is something that is very nice for readers to see, as long as you are responsible with your tagging and don’t use an overwhelming number of tags.

    In order to display tags on your WordPress blog, you’ll just want to add this little code snippet whenever you want the tag cloud to display (usually in the sidebar or footer somewhere depending on your blogs layout).

    Here is the code you’ll need:

    <?php wp_tag_cloud(''); ?>

    WordPress also allows you to customize your cloud to display the way you want it to. Most people like to emphasize the most used tags by making their font much larger. You can determine the size using the following code:

    <?php wp_tag_cloud('smallest=8&largest=36&'); ?>

    In this example, the tags will be displayed in alphabetical order with the least used tags being 8px and the most used tags will be 36px. You can of course adjust this to meet your needs.

  • Leave a Comment
  • How To: Switching Your WordPress Blog’s Permalink Stucture

    As a follow up to yesterday’s post about WordPress permalink structure (where a good discussion took place in the comments), I decided today that I would dedicate a post to showing you how to switch your blog’s permalink structure without creating any invalid URL’s.

    The easiest way to accomplish this is to grab the Permalink Redirect plugin (my plugin review here) and activate it. Once activated, when you go into the Settings panel you should find a new tab called Permalink Redirect. Scroll down to the bottom of the page and you should see this:

    In the old permalink structures box, you can paste your current permalink structure there (depending on which you choose, something like /%year%/%monthnum%/%day%/%postname%/). If you are unsure what exactly to type, please refer to the permalink page on the WordPress Codex.

    Now save and go to the Permalinks tab. Select the custom field and type /%postname%/, then save.

    Now go to an old URL and it should automatically redirect you to the same post’s new URL.   The search engines will see the 301 redirect and update accordingly!

    Any questions? Feel free to comment below!

    Update: I believe the plugin has changed since this was written.  If you are comfortable updating your .htaccess file, you can instead redirect all your links to the new /%postname%/ url by adding the following:

    RedirectMatch 301 /([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ http://www.domain.com/$4

  • Leave a Comment
  • How To: Setting Up Your WordPress Permalink Structure

    One of the great things about using WordPress is the built-in SEO advantages that this software gives you over building static pages or other blogging software. You have an advantage from the start over others not using WordPress! With that said, there are a lot of SEO techniques that need to be set up or applied by the user. The permalink structure is one of these that you can easily set up when creating your blog and then forget about it.

    By default, your WordPress Dashboard gives you a 3 choices to choose from. The default permalink structure is a terrible option from an SEO standpoint and the other two aren’t bad, but they aren’t your best option. According to Matt Cutts at WordCamp 2007 (Matt is the lead guy for the Google Search team), the best permalink structure you can use is just the post title with hyphens. According to Matt:

    • Don’t put your blog at the root of your domain.
    • Name your directory “blog” instead of “WordPress”.
    • In URLs, no spaces are worst, underscore are better, dashes or hyphens are best.
    • Use alt tags on images: not only is it good accessibility, it is good SEO.
    • Include keywords naturally in your posts.
    • Make your post dates easy to find.
    • Check your blog on a cell phone and/or iPhone.
    • Use partial-text feeds if you want more page views; use full-text feeds if you want more loyal readers.
    • Blogs should do standard pings.
    • Standardize backlinks (don’t mix and match www with non-www).
    • Use a permanent redirect (301) when moving to a new host.
    • Don’t include the post date in your URL.

    For WordPress users, this is easy to set up. Go into your blog’s Options panel and click on the Permalinks tab. You should see the following:

    WordPress Permalink Structure

    Click the custom radio button and type /%postname%/ into the field. This is the most ideal setup for your WordPress blog.

    If you already have an established blog using another structure, you can easily use the Permalink Redirect WordPress plugin to redirect your posts to the new structure.

  • Leave a Comment