Creating a Custom Post Type in WordPress

Creating a custom post types in WordPress is very simple. All you need to do is register the custom post type.

Copy the function below to your theme’s function.php file

The function below adds a custom post type “Ideas” with the same columns.

register_post_type('ideas', array(
	'label' => __('Ideas'),
	'singular_label' => __('Ideas'),
	'public' => true,
	'show_ui' => true,
	'capability_type' => 'post',
	'hierarchical' => false,
	'rewrite' => false,
	'query_var' => false,
	'supports' => array('title', 'editor', 'author')

If you want to list the posts posted under the custom post type, you can use the query_posts function:

This entry was posted in General, Wordpress, Wordpress Hacks. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *