2017-04-15 38 views

回答

0

如果您有Cpanel或數據庫訪問權限,則可以在DB面板中運行此查詢。

update table wp_posts set status='draft' where post_type='property_listing' 

否則,使用此代碼。(它粘貼在你的主題function.php)

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(); 
    } 
} 
相關問題