Creating posts

scribu edited this page Sep 15, 2012 · 8 revisions

Besides editing posts, it's also possible to create posts from the front-end.

Important: For post creation to work properly, go to WP Admin -> Settings -> Front-end Editor and make sure the "Edit all post fields at once." box is checked.

Then, for example, if you want to show the form on the front page, you would do that in the home.php template file:

<?php fee_inject_dummy_post( 'post', false ); ?>

<?php while ( have_posts() ) : the_post(); ?>
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <?php the_title(); ?>

        ...
    </article>
<?php endwhile; ?>

The post_class() call is mandatory; otherwise, FEE won't know how to find the post.

fee_inject_dummy_posts() accepts two arguments:

  • $post_type - The type of post you want to create (Default: post)
  • $replace_first - If it's set to true, the first post in the loop will be replaced with the post creation form