WordPress Insert Post from Front End

Hi, In this article I will show one example plugin for making post entry from wordpress front end.


Below is the sample code for the plugin

Plugin Name: Insert Post Fontend Demo Plugin
Plugin URI: http://thedigilife.com
Description: Example Insert Post Plugin and Approval from admin
Author: The Digi Life
Version: 1.0
Author URI: http://thedigilife.com
function display_insert_form($atts)
	if ( !empty($_POST) && !wp_verify_nonce($_POST['insert'],'insert_form') )
		echo 'Sorry, Problem in submitting form';
		// process form data
		$post_data = array(
		'post_title' => $_POST['title'],
		'post_content' => $_POST['description'],
		'post_status' => 'pending',
		'post_author' => 1,
		'post_category' => null
		if($post_id = wp_insert_post($post_data)) echo "Data Succcessfully added";
	<form action="" method="post" name="insert_form">
				<td><input type="text" name="title" id="title"></td>
				<td><textarea rows="7" cols="10" name="description" id="description"></textarea></td>
				<td colspan="2"><input type="submit" id="button"></td>
			<?php wp_nonce_field('insert_form','insert'); ?>

We can insert post in wordpress using wp_insert_post which is explained Here

In this sample I have created one sample shortcode for displaying plugin on front and in short code function I have added form to display and before that if post is submitted we will insert the post into database.

 Download | Source Code