To register the custom post types in WordPress, you can write the code manually:
The initial code to add a new custom post type should look like this:
//function.php
// The custom function MUST be hooked to the init action hook
add_action( 'init', 'ahmedcode_custom_post_article' );
// A custom function that calls register_post_type
function ahmedcode_custom_post_article() {
// Set various pieces of text, $labels is used inside the $args array
$labels = array(
'name' => _x( 'Custom Articles', 'post type general name' ),
'singular_name' => _x( 'Custom Article', 'post type singular name' ),
...
);
// Set various pieces of information about the post type
$args = array(
'labels' => $labels,
'description' => 'My custom post type',
'public' => true,
...
);
// Register the post type with all the information contained in the $arguments array
register_post_type( 'article', $args );
}
Code language: PHP (php)