Creating WordPress 3.0 themes including new features
Posted by: Nuwan Sameera Hettiarachchi on: July 15th, 2010
In: Web,WordPress Comments!

WordPress 3.0 was released couple of weeks ago. It is included lot of new features and functionality updates. With new features the WordPress seems to be a grate CMS among others CMSs. Actually WordPress templating is so easy when compare other major CMSs.

Before released WordPress 3.0, it had only one Post type to add article. But 3.0 has grate feature Custom Post Type . This feature will easy to hold and display many different types of content.

As well as another main issue also was solved with this introducing by Custom Post Types. The problem was URL suture of web site. Most of time post URL was Base_URL/blog/%date%/%post_name%/. But my opinion is URL should be best way to have as following
Base_URL/blog/%post_name%/ . Your know this format can be enabled old system. But we couldn’t set different kind of URL formats to the post. But this feature is come with Custom Post Type. We can have different kind of post urls. For examples you have a Magazine and Project in your organization. Now you can separately maintain two Post Type and you can assign the URL format for each post type.

I developed a new web site using WordPress 3.0 with new features. I created new two Custom Post Type for pages name called Magazine and Project.

You can create Custom Post type as Follows, Note: Let’s create Custom Post Type name as “Project

<?php
	register_post_type( 'projects',
                array('label' => __('Projects'),
			'public' => true,
			'show_ui' => true,
			'supports' => array('title','editor','author','thumbnail','excerpt','comments', 'custom-fields'),
			'menu_position' => 5
			)
              );
?>

And you can taxonomy for each Custom Post Types.

function create_my_taxonomies(){
    register_taxonomy( 
                          'projects-category', 
                          'projects', 
                          array( 'hierarchical' => true, 
                                   'label' => 'Categories', 
                                   'query_var' => true, 
                                   'rewrite' => array( 'slug' => 'projects/category' ) 
                       ));
 
   register_taxonomy( 
                         'projects-tags', 
                         'projects', 
                         array( 'hierarchical' => false, 
                                  'label' => 'Post Tag', 
                                  'query_var' => true, 
                                  'rewrite' => array( 'slug' => 'projects/tags' ) 
                        ));
}
//create taxomony
add_action( 'init', 'create_my_taxonomies',0 );

Above code will create a Custom Post Type and you can see it at backend in WordPress. Now you can create post under the “Project” post type as default “post” main type used by the blog in WordPress.

I will provide more details about complete WordPress 3.0 template creating on next posts.

I addition to WordPress having grate ability to change admin interface, just like organize Main menu order and remove some component without directly editing the core of WordPress.

Here is one of tip I just used today. Let’s think you don’t need WordPress default the Blog post type in your developed theme. As I shown above the codes, you have create your own Custom Post Types and you have a fully control of the web site with them. But you may not need default Post type anymore. So you can remove it form back-end main menu.

Just add hooks to the functions.php

function remove_menu() {
	global $menu;	
	$menu[0] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'open-if-no-js menu-top', 'menu-posts', 'div' );
	//remove post top level menu
	unset($menu[0]);
}
 
add_action('admin_head', 'remove_menu');

I think this will help to understand backend configuration using simple and smart hooks of WordPress :)