How to add frontend post / content addition option in WordPress
Step 1. Create a new page with this page template
Step 2. Fill the form, to create a post
Step 3. Check Dashboard, post added or not.
Note: You can change post type and status from here
Step 2. Fill the form, to create a post
Step 3. Check Dashboard, post added or not.
Note: You can change post type and status from here
- 'post_type' => 'post',
- 'post_status' => 'publish'
- /**
- * Template Name: Front End Submission
- */
- get_header(); ?>
- /** If sent, analyze form data and store them in variables*/if (isset($_POST['submit'])) {$name = htmlspecialchars($_POST['myname']);$email = sanitize_email($_POST['myemail']);$message = wp_kses_post($_POST['mymessage']);/** Create a post for post type "post"*/$contact_post = array('post_title' => $name . ' | ' . $email,'post_content' => $message,'post_type' => 'post','post_status' => 'publish');if (wp_insert_post($contact_post)) echo 'Post Added for admin review.
';else echo 'Try again: fill the fields';/** Displaying the basic form*/} else { ?>} ?> - get_sidebar(); ?>
- get_footer(); ?>