I want to have a very specific post "type". I would like to get rid of the title and content box, and add a "Name" field and an "Age" custom field. This way when I go to create a new post, it's like creating a new "person" With their name and age. I'm trying to do this, so that I can hopefully use a JSON api plugin so that I can feed this into a JSON api for myself. Any suggestions?
2 Answers
I would add my Custom Post Type (Person).
You can do this with register_post_type
function.
Then you have to add your custom fields. And the easiest way to do this will be Advanced Custom Fields plugin.
It allows you to define additional custom field groups that will be added to posts (based on some rules). It also allows you to hide parts of default WordPress editor.
Yu can use the folowing code for creating a custom post type
function create_post_type()
{
register_post_type('Custom_post_type_1',
array(
'labels' =>
array(
'name' => __('Games'),
'singular_name' => __('Game')
),
'public' => true,
'menu_position'=> 5,
'rewrite' => array(
'slug'=>'CPT1'
),
'support' => array('comments','author')
)
);
}
add_action('init','create_post_type');