» WordPress Coding & Design » Your Theme and WordPress 2.7

SarahYour Theme and WordPress 2.7

Written by Sarah from Stuff By Sarah on November 23, 2008

With the release of WordPress 2.7 just around the corner, it’s time to check on your theme and add in the new functionality available to make the most of it. Also, if you currently offer themes either as free or premium, then these changes are definitely something you need to be adding in.

There are 3 main changes for your theme files to consider - Post Classes, Logout Links and Comment Display.

Post Classes

The first new feature is a new template tag post_class(). This should be used within the loop to replace the class given on each post container, usually a div. You’ve possibly got an opening div within the loop (so it wraps around each post on say the front page) which looks something like

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

With the new post class feature, we replace the class with the new template tag ie.

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

This addition will then add a number of classes to the div such as post, category-slug, tag-slug (where ’slug’ is the slug for the category/tag). It will also add the class ’sticky’ for those that have been made a sticky post in the admin (a new feature of WordPress 2.7).

You can also pass parameters to this function, which will then be added to the class list. So for example, if you wanted to use a class called ‘entry’ (another popular class name with existing themes), you could add this in as a parameter. You can add in multiple additional class names, just separate them with a space eg.

<div id="post-<?php the_ID(); ?>" <?php post_class('entry class2'); ?>>

Logout Link

Most themes have a log out link at least in the comments.php template. Up until now the code for this has been similar to

To logout, <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">click here</a>

This can be found in the comments.php template file, usually just above the comment form.

We now need to change the URL to log out from

<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout

to

<?php echo wp_logout_url(get_permalink()); ?>

The parameter in this function is then read as the redirect URL once the user has logged out, so they’ll be redirected back to the page where the link was clicked.

Note, this doesn’t apply to the meta area that is sometimes found in the sidebar. This link is already toggled between log in and log out (depending on your status) using the wp_loginout() function.

Next week I’ll explain the new features for comments and how to update your theme to work with these. For those who are not already aware, the new features are pagination and comment threading.

  1. WordPress 2.7 Theme Enhancements II
  2. WordPress 2.7 Theme Enhancements III

Written by Sarah from Stuff By Sarah on November 23, 2008 | Filed Under WordPress Coding & Design

Share with others

  • StumbleUpon
  • Add to Delicious
  • Mixx
Make money with LinkXL

16 Responses so far | Have Your Say!

  1. Logo Design Blog  |  November 23rd, 2008 at 10:52 am #

    Logo Design Blog - Gravatar

    I have just published a Logo Design Blog using WordPress and am currently hoping to get some feedback on what I have done so far. So if any of you have the time would be most appreciated as I am new to the world of WordPress and am kind of learning as I go for my blog.

  2. ru4real?  |  November 23rd, 2008 at 5:43 pm #

    ru4real? - Gravatar

    Great info, Sarah …. I’ve bookmarked this page for use when the new release becomes official.

  3. Link Analysis  |  November 24th, 2008 at 9:54 am #

    Link Analysis - Gravatar

    Haizz… Once it’s released, I’m just going to press “Upgrade Automatically”. Those coding just gives me headache.

  4. Sarah (Post Author)   |  November 24th, 2008 at 10:05 am #

    Sarah - Gravatar

    Upgrade Automatically isn’t going to upgrade your theme, it just upgrades the core files i.e. everything besides anything under the wp-content folder. The post above explains 2 very basic changes that will benefit your blog’s theme, however as explained, they’re not necessary, they’re just enhancements to make things easier/better.

    Providing you don’t want to use the benefits of the new 2.7 enhancements then keep your theme as it is, no coding changes required :)

  5. Dennis Edell  |  November 24th, 2008 at 12:31 pm #

    Dennis Edell - Gravatar

    I’ll be passing this on to my designer, thanks!

  6. Play Games Win Prizes  |  November 24th, 2008 at 6:48 pm #

    Play Games Win Prizes - Gravatar

    I hate how Wordpress is doing this to some of us! lol. They update and we may have to pay to get things fixed.

    -Mike

  7. Sarah (Post Author)   |  November 25th, 2008 at 3:26 am #

    Sarah - Gravatar

    Hi Mike, as I’ve already explained, these are not necessary changes. You don’t need to change your theme for WordPress 2.7, just like you possibly didn’t update your theme when 2.5 came out.

    They’re additional features, extra options you can take advantage of. If you want to, then you can use them and at that point you’d need to make the changes. However to be fair, the two I’ve listed above would take 5 minutes work so if you want to get them added just post up in the Blogging Tips Forums and someone will help you out.

    However if you have no use for the additional post classes, you’re not fussed on the log out link (it’s not something I actively use for example) and you won’t be wanting to use the new comment features, then you can leave your theme as it is.

  8. bigbox  |  December 11th, 2008 at 11:52 pm #

    bigbox - Gravatar

    I also try to update my blog to the new released of wordpress and got the errors in my current theme, thank you for your instruction I’ll follow that.

Trackbacks to 'Your Theme and WordPress 2.7'

  1. Upcoming WordPress v2.7 Notes For Theme Designers | Money Maker
  2. BlogBuzz November 29, 2008 | Webmaster-Source
  3. WordPress 2.7 Theme Enhancements II
  4. Updating your Theme for Wordpress 2.7 :: Stuff by Sarah
  5. Wordpress 2.7 Güncellemesi Geçiş Notları
  6. WordPress 2.7 Released
  7. WordPress 2.7 Theme Enhancements III
  8. DurmaPaylas.Net » Blog Arşivi » Wordpress 2.7 Güncellemesi Geçiş Notları

Comments are closed since this post is older than 30 days. However, you can continue this discussion in our popular Blogging Forums