php - Edit form for custom loop post -
so, have custom loop post.
on page, have 10 posts 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 , price based on data-mail_id
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 add edit form (<form>
) edit post contents?
i guessing need following:
- get
<form>
targetedpost-mail_id
data such title. - change contents of post
- submit change update data specific
post-mail_id
.
what guys think?
edit 1:
well, not sure if correct, 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, what? lol
so, can show original title in input field. not sure how change can submitted , updated.
Comments
Post a Comment