Skip to content

WordPress 2.5 New Template Conditionals

WordPress 2.5 has been released. According to the release announcement:

The improvements in 2.5 are numerous, and almost entirely a result of your feedback: multi-file uploading, one-click plugin upgrades, built-in galleries, customizable dashboard, salted passwords and cookie encryption, media library, a WYSIWYG that doesn’t mess with your code, concurrent post editing protection, full-screen writing, and search that covers posts and pages.

My first look indicates that the WYSIWYG editor, based on Moxiecode's TinyMCE, version 3.0, still messes with code and produces invalid XHTML. If you want to keep the code in your posts valid, you still need to disable the editor and create your own X/HTML instead. Disabling wpautop and wptexturize also helps.

WordPress 2.5 certainly has some very nice features that will do a lot to keep WordPress the most popular choice for a blogging platform. You can read all about them at http://wordpress.org. For theme designers, a significant change has been brought in by the introduction of a new template conditional tag.

New Template Conditional

For over a year, developers have been discussing the problems of using a static front page which may, or may not, be including the loop. In the last few releases there have been a lot of changes and messing around with the is_home() conditional tag. This appears to have finally been resolved.

As of 2.5, is_home() returns true for the blog home page - the page where your posts are displayed (usually using index.php)

Front Page

WordPress now treats the front page of the site (also called the index page, and in web site terms called the home page) differently. I predict that this is going to cause a lot of confusion to users and theme developers so here goes with an explanation.

The new template conditional is is_front_page().

This will return true if your site's frontpage is being displayed, if that frontpage is part of WordPress. If you are using index.php or other main blog page which displays your posts, then both is_home() and is_front_page() will return true. In this situation you should simply use is_home().
If you are using another page or post as the front page to your site, then is_front_page() is the tag to use. This can be used on either dynamic or static front pages and will make it much easier to integrate a front page that has a different look and content to the rest of your blog.

For the developers amongst us, this new conditional can be found in wp-includes/query.php.

Apart from all the new features WP 2.5 brings, it also patches some security issues. If you are using an older version of WordPress it is strongly advised to upgrade.

If you enjoyed this post, make sure you subscribe to my RSS feed!

Topic: WordPress
Tagged as: blogging, bug fixes, conditionals, security patch, templates, WordPress themes

Share on FriendFeed

{ 4 comments… read them below or jump to the comment form to add your thoughts }

  1. 1 RaiulBaztepo March 29th, 2009 at 3:22 pm

    Hello!
    Very Interesting post! Thank you for such interesting resource!
    PS: Sorry for my bad english, I'v just started to learn this language ;)
    See you!
    Your, Raiul Baztepo

  2. 2 PiterKokoniz April 8th, 2009 at 1:11 pm

    Hi ! ^_^
    I am Piter Kokoniz. Just want to tell, that your posts are really interesting
    And want to ask you: is this blog your hobby?
    Sorry for my bad english:)
    Thank you:)
    Your Piter

  3. 3 Lynne Pope April 9th, 2009 at 12:25 pm Lynne Pope

    Yes, this blog is my hobby - its my way of sharing information about web design and open source software. I'm glad you find my posts interesting :)

  4. 4 Ariana May 13th, 2009 at 9:18 pm

    hi, thanks,The article was very well written, very helpful to me

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Any comments that look like spam will be treated as spam - this includes SEO titles and use of spurious keywords.

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution.