<?php
include ('./wp-config.php');
$pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8', DB_USER, DB_PASSWORD);
// 該当カテゴリのPOST_IDの配列を生成
$post_id_array = array();
$sql = "SELECT * FROM `mint_term_relationships` WHERE `term_taxonomy_id` = '2'"; // カテゴリIDを指定
foreach($pdo->query($sql) as $item) {
array_push($post_id_array, $item[object_id]);
}
var_dump($post_id_array);
// 公開フラグを変更する
for($i = 0; $post_id_array[$i] != ''; $i ++){
// 公開
// $sql = "UPDATE `mint_posts` SET `post_status` = 'publish', `comment_status` = 'open', `ping_status` = 'open' WHERE `ID` = '$post_id_array[$i]'";
// 非公開
$sql = "UPDATE `mint_posts` SET `post_status` = 'inherit', `comment_status` = 'closed', `ping_status` = 'closed' WHERE `ID` = '$post_id_array[$i]'";
$statement = $pdo->query($sql);
}
?>