I am trying to build my own lightweight plugin that will register Custom Post Types. The problem I am having is that I can create a post type but I can't figure out how to save the previous post type and then create another one with each new entry.
function create_custom_post_type() {
if (isset($_POST['tme_post_type_singular'])) {
update_option('tme_post_type_singular', $_POST['tme_post_type_singular']);
$value = $_POST['tme_post_type_singular'];
}
$value = get_option('tme_post_type_singular', '');
if (isset($value)) {
$custom_posts = array(
"slug" => $value,
"name" => $value . 's',
"singular_name" => $value,
"is_public" => true,
"has_archive" => false,
);
register_post_type( $value,
array(
'labels' => array(
'name' => __( $custom_posts['name'] ),
'singular_name' => __( $custom_posts['singular_name'] )
),
'public' => true,
'has_archive' => true,
)
);
}
}
add_action( 'init', 'create_custom_post_type' );
How can change this code to allow me to create more than one post type every time I input new entries?