如何在post ID数组上运行wp\\u update\\u post函数。它似乎对数组没有响应,尽管我没有收到错误并且似乎只对一个数组有效?
$post_id = array(1235,1234,1228, 1221, 1211, 1212, 1208, 1200);
$post = array( \'ID\' => $post_id, \'post_status\' => \'pending\' );
wp_update_post($post);
如何在post ID数组上运行wp\\u update\\u post函数。它似乎对数组没有响应,尽管我没有收到错误并且似乎只对一个数组有效?
$post_id = array(1235,1234,1228, 1221, 1211, 1212, 1208, 1200);
$post = array( \'ID\' => $post_id, \'post_status\' => \'pending\' );
wp_update_post($post);
wp_update_post
“ID”应为单个post ID,而不是数组。你需要分别处理每个帖子。
尝试:
$post_ids = array( 1235, 1234, 1228, 1221, 1211, 1212, 1208, 1200 );
foreach($post_ids as $post_id) {
$post = array( \'ID\' => $post_id, \'post_status\' => \'pending\' );
wp_update_post($post);
}
我有一个简单的短代码来显示最近的帖子及其标题,除了:add_shortcode(\'latest3\', function(){ $recent_posts = wp_get_recent_posts( array( \'numberposts\' => 3, \'orderby\' => \'post_date\',