0
기능을 삭제합니다 :패스 ID가 나는 다음과 같은 워드 프레스 페이지 템플릿을 만든
<?php
/* Template Name: Report Creator */
get_header();
wp_enqueue_style('wp-admin');
?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
?>
<style>
.table td{
padding-left:0;
}
</style>
<!-- ############################### -->
<?php
if(isset($_POST['function-action'])){
$function_action = $_POST['function-action'];
switch($function_action){
case 'form-edit-profile':
break;
case 'form-delete-profile':
wp_delete_post(); //pass ID over here to delete the post
break;
default:
break;
}
}
?>
<table>
<tr>
<th>Titel</th>
<th>Creation Date</th>
<th>Next fetch time</th>
<th># of Recipience</th>
<th>Functions</th>
</tr>
<?php
if (is_user_logged_in()):
global $current_user;
$author_query = array('post_status' => array('draft'),
'author' => $current_user->ID,
'meta_query' => array(
array(
'key' => 'wpgamail_options',
'key' => 'ganalytics_settings',
),
),);
$author_posts = new WP_Query($author_query);
while($author_posts->have_posts()) : $author_posts->the_post();
?>
<tr>
<td>
<?php the_title(); ?>
</td>
<td>
<?php $post_date = get_the_date(); echo $post_date; ?>
</td>
<td>
<?php $field = get_field('wpgamail_options', get_the_ID(), true); echo "Next report on " . date('l jS \of F Y h:i:s A', $field['nextfetchtime']); ?>
</td>
<td>
<?php echo count($field['recipients']) . " Recipient"; ?>
</td>
<td>
<form method="post">
<input type="hidden" name="function-action" value="form-edit-profile"/>
<input type="submit" value="Edit Profile" class="button button-primary" />
</form>
</td>
<td>
<form method="post">
<input type="hidden" name="function-action" value="form-delete-profile"/>
<input type="submit" value="Delete Profile" class="button button-primary" onclick="return confirm('Do you really want to delete the report-settings?')" />
</form>
</td>
</tr>
<?php
endwhile;
else :
echo "You are not logged in. Please log in!";
endif;
?>
</table>
<hr/>
</main>
<!-- .site-main -->
</div>
<!-- .content-area -->
<?php get_footer(); ?>
내 문제는 내가 순서대로 switch-case
구조에 현재 선택한 게시물의 ID를 전달하는 방법을 모르겠입니다 게시물 delete/edit
합니다.
어떻게해야할까요?
답장을 보내 주셔서 감사합니다.
'wp_delete_post (this.id);'??? –
'wp_delete_post (get_the_ID());'가 작동합니다. –
@BhojendraNepal 귀하의 회신에 감사드립니다! 그러나'wp_delete_post (this.id);'는 작동하지 않습니다. – mrquad