wp_update_post
을 사용하여 category
게시물을 변경하고 업데이트하고 싶습니다. 카테고리를 변경하려면 <a>
또는 <button>
앵커에서 wp_update_post 카테고리를 클릭하십시오.
을 클릭하여 변경해야합니다. 내가 알기 론, 게시물에 대한 업데이트가 적용되어야합니다. 테마의 기능에 대한 자세한 내용
업데이트 우편 번호 - - 아직 테스트하지
$live_paused = array(
'post_category' => 6
);
// Update the post into the database
wp_update_post($live_paused);
그러나 어떻게이
echo '<a href="" id=""><i class="fa fa-pause"></i></a>';
편집에이 기능을 추가 설정할 수 있습니다.
function live_paused_status($post_id){
if (current_user_can('edit_post', $post->ID)) {
$live_paused = array(
'post_category' => 6
);
echo '<a href="" id=""><button title="" data-toggle="tooltip" class="campaigns-link-button" type="button" data-original-title="Pause Campaign"><i class="fa fa-pause"></i></button></a>';
// unhook this function so it doesn't loop infinitely
remove_action('save_post', 'live_paused_status');
// update the post, which calls save_post again
wp_update_post($live_paused);
// re-hook this function
add_action('save_post', 'live_paused_status');
}
}
add_action('save_post', 'live_paused_status');
당신은 후크 스크립트에 AJAX 요청을해야
<?php $query = new WP_Query(array('post_type' => 'campaigns'));?>
<?php if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); ?>
<div class="card">
<div class="card-footer">
<div class="row">
<div class="col-4 campaigns-link">
<?php echo live_paused_status(); ?>
</div>
</div>
</div>
</div>
<?php endwhile; wp_reset_postdata(); ?>
그냥 ajax를 사용하십시오. 그게 다야. –
고맙습니다, 디팍. 질문에 대답을 할 수있는 기회가 생길 수 있습니다. 건배. – Darren
루프 및 업데이트 게시물 코드 –