So, I have a custom loop post.
On the page, I have 10 posts as below:
<?php
$args = array(
'post_type' => 'mail',
'paged'=>$paged,
'posts_per_page' => 10,
'mail_cat' => '',
'orderby' => 'date',
'order' => 'DESC',
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
?>
Each post gets title, content and price based on the data-mail_id
as below:
<div data-mail_id="' . esc_attr( $mail->id ) . '">
<?php the_title(); ?>
<?php the_content(); ?>
<?php echo $mail->get_price_html(); ?>
</div>
Now, how can I add an edit form (<form>
) to edit the post contents?
I am guessing I need following:
- Get the
<form>
with the targetedpost-mail_id
data such as title. - Change the contents of the post
- Submit the change which will update the data for that specific
post-mail_id
.
What do you guys think?
EDIT 1:
Well, I am not sure if this is correct, but it is a start :p
<form role="form" method="post">
<?php wp_nonce_field( 'update_post_'. get_the_ID(), 'update_post_nonce' ); ?>
<div id="title_change">
<input type="text" id="post_title" name="post_title" value="<?php echo $post->post_title; ?>"></input>
<input type="submit" name="update" type="submit" ></input>
</div>
</form>
So, now what? lol
So, I can show the original title in the input field.
I am not sure how the change can be submitted and be updated.