The WordPress 3.0 functions.php File

Published 23rd April 2010

WordPress 3.0 looms on the horizon with loads of great new features including custom navigation menus, custom header and background management, proper support for custom post types and taxonomies, multi-site feature (WPMU), custom author profiles, I could go on. Anyway so what I want to show you today is how to prep your WordPress theme so that you can include all of these cool features. This is done by simply including a bunch of code in your functions.php file.

<?php //Custom nav menu support add_theme_support('nav-menus'); //Usage: wp_nav_menu(array('sort_column' => 'menu_order', 'container_class' => 'menu-header')); //Automatically add Feed links add_theme_support('automatic-feed-links'); //Post thumbnails (was available in v2.9) add_theme_support('post-thumbnails'); //Usage: the_post_thumbnail(); //Custom background add_custom_background(); //Custom header //The %s is a placeholder for the theme template directory URI. define('HEADER_IMAGE', '%s/images/header.png'); //The default header define('HEADER_IMAGE_WIDTH', apply_filters('', 800)); //Width of header define('HEADER_IMAGE_HEIGHT', apply_filters('', 200)); //Height of header define('NO_HEADER_TEXT', true); add_custom_image_header('', 'admin_header_style'); //This Enables the Appearance > Header //Following Code is for Styling the Admin Page if(!function_exists('admin_header_style')){ function admin_header_style() { ?> <style type="text/css"> #headimg { height: <?php echo HEADER_IMAGE_HEIGHT; ?>px; width: <?php echo HEADER_IMAGE_WIDTH; ?>px; } #headimg h1, #headimg #desc { display: none; } </style> <?php } } //Custom post types and taxonomies example function post_type_albums() { register_post_type( 'albums', array( 'label' => __('Albums'), 'public' => true, 'show_ui' => true, 'supports' => array( 'post-thumbnails', 'excerpts', 'trackbacks', 'comments' ) ) ); // Adding the Custom Taxonomy for Genres. Here we can create categories specific for this post type. register_taxonomy( 'genres', 'albums', array( 'hierarchical' => true, 'label' => __('Genres') ) ); // Adding the Custom Taxonomy for Performer. Here we can add tags specific for this post type. register_taxonomy('performer', 'albums', array( 'hierarchical' => false, 'label' => __('Performer'), 'query_var' => 'performer', 'rewrite' => array('slug' => 'performer') ) ); } add_action('init', 'post_type_albums'); ?>

So there you have it. Some of the newest and coolest WordPress 3.0 features now available in your WordPress themes. Thanks to and for the information.