How to add custom post in WordPress

Hi Kids,

If you want to add custom post in wordpress, aside from the default POST and PAGE type posts.
all you have to do is add this piece of code in your functions.php

You have to change the “custompost “variable though.

register_post_type(
 'custompost',
 array(
  'labels' => array(
  'name' => __( 'Custom Post' ),
  'singular_name' => __( 'Custom Post' ),
  ),
  'description' => __('Custom Post'),
  'public' => true,
  'register_meta_box_cb' => 'custompost_meta_boxes',
  'show_ui' => true,
  'supports' => array(
   'title',
   'editor',
   'author',
   'excerpts',
   'custom-fields',
   'revisions',
   'thumbnail'
  )
 )
);

register_taxonomy_for_object_type('category', 'custompost');
register_taxonomy_for_object_type('post-tag', 'custompost');

function custompost_meta_boxes() {
 //add_meta_box( 'testpost_meta', __('TEST POST'), 'testpost_meta_box', 'testposts','normal', 'high' );
}

Alrigh kids,

Ciao!!!

It's only fair to share...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Leave a Reply

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