我正在尝试通过我的SQL
文件运行一个functions.php
查询,一旦可行,将其移动到插件中,并通过激活该查询来运行。然后,我可以通过激活/停用插件来运行查询。
目标是将状态为published
的所有产品更改为drafts
。这就是我得到的,这不起作用。
这里有谁可以帮助您?
add_action('wp_head','turn_all_products_into_drafts');
function turn_all_products_into_drafts(){
include_once("wp-config.php");
include_once("wp-includes/wp-db.php");
global $wpdb;
$sql = "UPDATE wp_posts SET post_status = 'draft' WHERE post_type = 'product' AND post_status = 'publish'";
$wpdb->update($sql);
}
答案 0 :(得分:0)
可能是您的拼写错误吗? 在说明中,您说:
状态为已发布
,然后选择:
post_status ='发布'