WordPress is no more a blogging platform. People always tried to use it as CMS by applying their own techniques and ways. Wordpress kept on adding new feature in this direction in their releases. One of the most important addition to wordpress in this direction is Custom Post Types. One of the major requirement when using wordpress as a CMS.
For example, say you are creating a Travel website listing restaurants & hotels.
You would need 2 post types.
Now you could add custom post type by adding this small piece of code to your functions.php file within your theme folder:
Here is what the above code in your function.php do:
It's that simple. Now if your curios on how to show post on your home there is a nice write up by
For example, say you are creating a Travel website listing restaurants & hotels.
You would need 2 post types.
- Restaurant
- Hotel
Now you could add custom post type by adding this small piece of code to your functions.php file within your theme folder:
//Add restaurant
function post_type_restaurant() {
register_post_type( 'restaurant', array(
'label' => __('Restaurant'),
'public' => true,
'show_ui' => true ) );
//registers a taxonomy for this post type
register_taxonomy_for_object_type('post_tag', 'restaurant');
}
add_action('init', 'post_type_restaurant');
Here is what the above code in your function.php do:
It's that simple. Now if your curios on how to show post on your home there is a nice write up by
Comments
Post a Comment