How To Make Your Theme Compatible to WordPress 3.0

WordPress 3.0 released last week with lots of new user-friendly features but most blogs/websites using WordPress are facing a unique problem. The problem being the incompatibility of current WordPress themes to the latest WordPress package which has been named ‘Thelonious’ this time. To overcome this problem there have been a few posts around with some of them getting lots of hits across the internet. To accommodate all the new features, your theme needs to undergo some changes. Today, I’ll be introducing the way I used to make my theme compatible to WordPress 3.0. So let’s get started!

Enable Custom Backgrounds for your Theme

Adding this functionality to your theme is pretty easy. Just add the following code to your functions.php file:

add_custom_background();

Now you can change the theme background by either changing its color or uploading a background image or both. And you can do all this using the WordPress Admin section without having to touch a single line of code.

Adding Feed Links automatically into Your Theme

This feature has been out since WordPress 2.8 but a custom code for doing so was added in this release. Earlier people had to add the code below to their header.php files to add those multiple feed links to your theme header.

<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />

Now you can just add the following code to your functions.php file and you are good to go:

add_theme_support( 'automatic-feed-links' );

Adding Support For Post Thumbnail Images

Originally this feature was added in WordPress 2.9 but I thought to reshare it in this article. Older WordPress themes used the custom fields to use this feature but after the launch of WordPress 2.9, you can upload an image and set it as the post thumbnail, but this can only be done if your theme supports it. To add this support just add the following code to the functions.php file:

add_theme_support( 'post-thumbnails' );

That will enable Post Thumbnail UI for both Post and Page content types. If you’d only like to add it to either the page template or the post template then you can do it using the following code:

add_theme_support( 'post-thumbnails', array( 'post' ) ); // Add it for posts
add_theme_support( 'post-thumbnails', array( 'page' ) ); // Add it for pages

And then you can call this function on the single.php page template using the code below:

<?php the_post_thumbnail(); ?>

Once you enable this, you can set the Featured Image or the Thumbnail image for the post using the widget that automatically appears on the post editor right sidebar, below categories and post tags (widgets).

For More: Read this for more on this topic Enabling Post Thumbnail Images, check here.

Enable Navigation Menu Editor for Easy Menu Management

This is the one of the most exciting features that ships with WordPress 3.0 but works only with the themes compatible to WordPress 3. The old themes won’t have this feature pre-enabled and for that you’ll need to make some additions and subtractions to your theme files. This feature allows the users to manage the navigation menu from Dashboard, right under the Appearance settings and adds a new item Menus.

To enable this, add the following to the functions.php of your theme:

add_theme_support( 'nav-menus' );

To call the menu into the theme, add the following to the header.php:

<?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'container_class' => 'menu-header' ) ); ?>

where menu-order is the css class for the menu. You will have to change this according to the theme style-sheet.

For More: Read this for more on this topic How to Add Custom Navigation Menus in WordPress 3.0 Themes

Enable multisite feature

The most exciting feature and distinguishing feature of WordPress 3.0 is the merging oof WordPress MultiSite (MU) and WordPress Single Site installation. To enable this feature just add the following code to your wp-config.php file:

define('WP_ALLOW_MULTISITE', true);

After that you can access WordPress MultiSite by going to the Network settings under Tools section on your blog Dashboard. This adds a great functionality to your old WordPress theme + your website/blog and makes your internet life even more interesting.

Enable Custom Header Management to Change Header background of your theme easily

Last but not the least, WordPress 3 introduces the much anticiapated function, you can now change the header image of your theme to personlize it according to your needs and taste.

Add the following code to your functions.php file:

define( 'HEADER_IMAGE', '%s/images/logo.png' ); // The default logo located in themes folder
define( 'HEADER_IMAGE_WIDTH', apply_filters( '', 770 ) ); // Width of Logo
define( 'HEADER_IMAGE_HEIGHT', apply_filters( '', 153 ) ); // Height of Logo
define( 'NO_HEADER_TEXT', true );
add_custom_image_header( '', 'admin_header_style' ); // This Enables the Appearance > Header
// Following Code is for Styling the Admin Side
if ( ! function_exists( 'admin_header_style' ) ) :
function admin_header_style() {
?>
<style type="text/css">
#heading {
height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
width: <?php echo HEADER_IMAGE_WIDTH; ?>px;
}
#heading h1, #heading #desc {
display: none;
}
</style>
<?php
}
endif;

And then you can call this feature using the following hook:

<?php header_image(); ?>

Below is an example of the hook shown above, I got this from the new default WordPress 3 theme – Twenty Ten:

<img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="Header Image" />

Custom author profiles

WordPress allows you to create author pages, but WordPress 3.0 is introducing a new function which will allow you to use different templates for different authors, like we can currently do with categories.

All you have to do is to create an author page named author-XX.php where XX is either the author ID or nicename. For example, if your user nicename is “tw”, you’ll have to call the file author-tw.php.

I think that’s it for now! If you have anything else to add to this list then feel free to comment on this post :)

You can leave a response, or trackback from your own site.

5 Responses to “How To Make Your Theme Compatible to WordPress 3.0”

  1. Stefano says:

    Enable Custom Header Management to Change Header background of your theme easily

    define( ‘HEADER_IMAGE_WIDTH’, apply_filters( ”, 770 ) ); // Width of Logo
    define( ‘HEADER_IMAGE_HEIGHT’, apply_filters( ”, 153 ) ); // Height of Logo

    Can you tell me how to read width/height of the image instead of to declare fixed dimensions ?
    Best regards

  2. Stefano says:

    SOLVED

    define( ‘HEADER_IMAGE’, ‘%s/images/header.jpg’ ); // The default logo located in themes folder
    $theme_name = get_current_theme();
    //echo $theme_name;
    list($width, $height, $type, $attr) = getimagesize(‘../wp-content/themes/’ . $theme_name . ‘/images/header.jpg’);
    define( ‘HEADER_IMAGE_WIDTH’, apply_filters( ”, $width ) ); // Width of header image
    define( ‘HEADER_IMAGE_HEIGHT’, apply_filters( ”, $height ) ); // Height of header image

  3. [...] How To Make Your Theme Compatible to WordPress 3.0 [...]

  4. wordpress templates…

    How To Make Your Theme Compatible to WordPress 3.0 | TutorialsWalk…

Leave a Reply