I want to record email address of user who are submitting their email address from userend.
<?php
$my_post = array(
'post_title' => 'Subscribed Email',
'post_content' => '[email protected]',
'post_status' => 'publish',
'post_author' => 1,
'post_type' => 'subscription',
);
$insertPost=wp_insert_post( $my_post );
?>
Here do i need to register subscription as a post type at first? Or it does not matter if i directly insert it with out registering post type?I do not need to show it on admin panel.
Your code will insert custom post type entry into the database even if you do not register custom post type before, but without registering custom post type you will not have permalink structure associated with CPT and will not be able to access it via url and you will not have an admin interface.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With