批量更新所有描述类别
Bulk update all description categories
我想在一个请求中设置所有描述类别:
global $wpdb;
foreach (get_categories() as $cat){
$wpdb->query(
"
UPDATE $wpdb->term_taxonomy
SET description = '".$cat->cat_name." '
WHERE wp_term_taxonomy.term_taxonomy_id = '".$cat->term_id."'
"
);
但没有成功。任何帮助谢谢
global $wpdb;
$wpdb->query('
UPDATE '.$wpdb->prefix.'term_taxonomy AS tt
INNER JOIN
'.$wpdb->prefix.'terms AS t
ON t.term_id = tt.term_id
SET tt.description = t.name
WHERE tt.taxonomy = "category"');
顺便说一下,在您的代码中,每次迭代都会发出一个新请求
我想在一个请求中设置所有描述类别:
global $wpdb;
foreach (get_categories() as $cat){
$wpdb->query(
"
UPDATE $wpdb->term_taxonomy
SET description = '".$cat->cat_name." '
WHERE wp_term_taxonomy.term_taxonomy_id = '".$cat->term_id."'
"
);
但没有成功。任何帮助谢谢
global $wpdb;
$wpdb->query('
UPDATE '.$wpdb->prefix.'term_taxonomy AS tt
INNER JOIN
'.$wpdb->prefix.'terms AS t
ON t.term_id = tt.term_id
SET tt.description = t.name
WHERE tt.taxonomy = "category"');
顺便说一下,在您的代码中,每次迭代都会发出一个新请求