Saturday, October 6, 2012

Wordpress front end editor

Ever got a requirement of retrieving customer submitted data and storing it into your post, page or custom post type in Wordpress.

Well, there is a simple editor function wp_editor() is available within wordpress.

Just put the following code, wherever you want to insert editor in the front end.

echo '<form action="" method="post">'; // Insert form to grab post data
wp_editor('<p>Hello</p>', 'textarea01' );
echo '<input type="submit" name="submit" value="Submit" /></form>' // Button to submit the data

You can insert any number of text fields to let user submit all the data regarding the particular post type. For example, you can also insert text input field for the title field of the post and another field for modifying the slug.

It 's upto you now, how you can take advantage of this simple editor interface on the front end.

Further, you can use wp_insert_post() function to insert new post into the wordpress.

<?php wp_insert_post( $post, $wp_error ); ?> 

For more information on wp_insert_post() refer

No comments:

Post a Comment