0
모든 사용자 정의 게시물 유형 상태 변경을 "게시"에서 임시로 변경하는 방법이 있습니까?사용자 지정 유형에 대한 이동 게시물 상태에 대한 Wordpress 일괄
시나리오 : 여기 스크립트를 실행해야합니다. 내 게시물 유형 : property_listing 이제 모든 초안을 작성한 다음 내 사용자 지정 작업을 수행해야합니다.
가능합니까?
모든 사용자 정의 게시물 유형 상태 변경을 "게시"에서 임시로 변경하는 방법이 있습니까?사용자 지정 유형에 대한 이동 게시물 상태에 대한 Wordpress 일괄
시나리오 : 여기 스크립트를 실행해야합니다. 내 게시물 유형 : property_listing 이제 모든 초안을 작성한 다음 내 사용자 지정 작업을 수행해야합니다.
가능합니까?
Cpanel 또는 데이터베이스 액세스 권한이있는 경우 DB 패널에서이 쿼리를 실행할 수 있습니다.
update table wp_posts set status='draft' where post_type='property_listing'
그렇지 않으면,이 코드를 사용합니다.
add_action('init','change_mypost_status');
function change_mypost_status(){
$args = array(
'post_type' => 'property_listing',
'posts_per_page' => -1
);
$the_query = new WP_Query($args);
if ($the_query->have_posts()) {
echo '<ul>';
while ($the_query->have_posts()) {
$the_query->the_post();
$current_post = array(
'ID' => get_the_ID(),
'post_status' => 'draft'
);
// Update the post into the database
wp_update_post($current_post);
}
wp_reset_postdata();
}
}
(테마의 function.php에 붙여 넣습니다)