php - 列出所有超过 28 个字符的分类
问题描述
我的网站上有一个问题,原因是属性分类过长。有人可以告诉我是否有办法直接在 DB 中查看更长的分类法?我需要查看所有超过 32 个字符的属性分类。
解决方案
if ( !empty( $_GET[ 'testmode' ] ) ) {
$terms = get_terms();
$maxlength_terms = array();
foreach ( $terms as $term ) {
if ( strlen( $term->name ) > 28 ) {
$maxlength_terms[] = $term;
}
}
foreach ( $maxlength_terms as $key => $max_term ) {
$update = wp_update_term( $max_term->term_id, $max_term->taxonomy, array(
'name' => substr( $term->name, 0, 28 ),
) );
}
}
尝试在您的活动主题 functions.php 中添加它并访问您的网站 URL,例如 www.yoururl.com?testmode=1
推荐阅读
- php - 在 PHP MYSQLI 中第二次查询数据库后出现异常未知错误
- r - 在 Shiny 中动态渲染盒子
- ibm-mobilefirst - 通过 REST API 注册推送通知后,设备未在 mfpconsole 中显示
- java - 无法实现斯坦福 CoreNLP 的 OpenIE 注释器的选项
- php - php imagick 脚本以错误 500 结尾
- angularjs - 无法使用 rquirejs 实例化模块 ui-mask angulajs
- javascript - Ajax 执行更新和删除页面不会自动刷新我正在使用 laravel 5.5
- amazon-s3 - aws cli s3 存储桶删除具有日期条件的对象
- javascript - 使用 nuxtjs 渲染数字
- asynchronous - 龙卷风,使 on_finish() 异步