MNews 升级到 MNews Pro 主题
数据修改可通过 Better Search Replace 插件或者使用 SQL 语句,插件更为简便,SQL 语句修改更为高效。
修改前请一定备份好数据库。
1、使用插件替换,输入要替换和替换的内容,选择对应的数据库表,「作为模拟运行」不要勾选,勾选了不会替换数据。
2、使用 SQL 替换,将 SQL 语句添加到输入框,一行一条语句,可多行,确定后点击「执行」即可完成。也可点击「模拟查询」,可查看是否有数据有被替换。
一、自定义类型文章
修改分类和标签
1、视频
搜索:vcat,替换为:video-cat,选择『wp_term_taxonomy』表
// SQL语句: update wp_term_taxonomy set taxonomy = replace( taxonomy, 'vcat', 'video-cat' )
搜索:vtag,替换为:video-tag,选择『wp_term_taxonomy』表
// SQL语句: update wp_term_taxonomy set taxonomy = replace( taxonomy, 'vtag', 'video-tag' )
搜索:time,替换为:video_duration,选择『wp_postmeta』表
// SQL语句: update wp_postmeta set meta_key = replace( meta_key, 'time', 'video_duration' )
搜索:youku_id,替换为:video_youku,选择『wp_postmeta』表
// SQL语句: update wp_postmeta set meta_key = replace( meta_key, 'youku_id', 'video_youku' )
搜索:qq_id,替换为:video_qq,选择『wp_postmeta』表
// SQL语句: update wp_postmeta set meta_key = replace( meta_key, 'qq_id', 'video_qq' )
搜索:小时,替换为:“:”,选择『wp_postmeta』表
// SQL语句: update wp_postmeta set meta_key = replace( meta_key, '小时', ':' )
搜索:分,替换为:“:”,选择『wp_postmeta』表
// SQL语句: update wp_postmeta set meta_key = replace( meta_key, '分', ':' )
搜索:秒,替换为:“”,选择『wp_postmeta』表
// SQL语句: update wp_postmeta set meta_key = replace( meta_key, '秒', ':' )
注:这个时间替换会出现没有秒时,最后会是:,需要查找每个视频文章,把后面的:去掉
注:视频模块需要到编辑视频文章页面的选项中再选择对应的视频类型,不选择是不显示视频,如下图
2、下载
搜索:dcat,替换为:download-cat,选择『wp_term_taxonomy』表
// SQL语句: update wp_term_taxonomy set taxonomy = replace( taxonomy, 'dcat', 'download-cat' )
搜索:dtag,替换为:download-tag,选择『wp_term_taxonomy』表
// SQL语句: update wp_term_taxonomy set taxonomy = replace( taxonomy, 'dtag', 'download-tag' )
3、专题
搜索:tcat,替换为:topic-cat,选择『wp_term_taxonomy』表
// SQL语句: update wp_term_taxonomy set taxonomy = replace( taxonomy, 'tcat', 'topic-cat' )
搜索:ttag,替换为:topic-tag,选择『wp_term_taxonomy』表
// SQL语句: update wp_term_taxonomy set taxonomy = replace( taxonomy, 'ttag', 'topic-tag' )
搜索:new_topic_post_id,替换为:topic_posts,选择『wp_postmeta』表
// SQL语句: update wp_postmeta set meta_key = replace( meta_key, 'new_topic_post_id', 'topic_posts' )
4、快讯
搜索:kx,替换为:moment,选择『wp_posts』表
// SQL语句: update wp_posts set post_type = replace( post_type, 'kx', 'moment' )
5、模板页面
所有模板页面都需要重新选择再保存
搜索:page_thumb,替换为:crumbs_bg,选择『wp_postmeta』表
// SQL语句: update wp_postmeta set meta_key = replace( meta_key, 'page_thumb', 'crumbs_bg' )
搜索:page_opacity,替换为:crumbs_opacity,选择『wp_postmeta』表
// SQL语句: update wp_postmeta set meta_key = replace( meta_key, 'page_opacity', 'crumbs_opacity' )
搜索:page_desc,替换为:crumbs_describe,选择『wp_postmeta』表
// SQL语句: update wp_postmeta set meta_key = replace( meta_key, 'page_desc', 'crumbs_describe' )
6、喜欢
搜索:salong_post_like_count,替换为:likes,选择『wp_postmeta』表
// SQL语句: update wp_postmeta set meta_key = replace( meta_key, 'salong_post_like_count', 'likes' )
搜索:salong_post_like_modified,替换为:like_modified,选择『wp_postmeta』表
// SQL语句: update wp_postmeta set meta_key = replace( meta_key, 'salong_post_like_modified', 'like_modified' )
7、评论
搜索:salong_comment_like_modified,替换为:like_modified,选择『wp_commentmeta』表
// SQL语句: update wp_commentmeta set meta_key = replace( meta_key, 'salong_comment_like_modified', 'like_modified' )
搜索:salong_comment_like_count,替换为:likes,选择『wp_commentmeta』表
// SQL语句: update wp_commentmeta set meta_key = replace( meta_key, 'salong_comment_like_count', 'likes' )
二、简码
1、消息
注:1、icon="1"
,其中的1为显示图标,设置为0则不显示图标
2、请将 {
替换为 [
,}
替换为[
搜索:{infobox}
,替换为:{salong-message style="info" icon="1"}
,选择『wp_posts
』表
// SQL语句: update wp_posts set post_content = replace( post_content, '{infobox}', '{salong-message style="info" icon="1"}' )
搜索:{successbox}
,替换为:{salong-message style="success" icon="1"}
,选择『wp_posts
』表
// SQL语句: update wp_posts set post_content = replace( post_content, '{successbox}', '{salong-message style="success" icon="1"}' )
搜索:{warningbox}
,替换为:{salong-message style="warning" icon="1"}
,选择『wp_posts
』表
// SQL语句: update wp_posts set post_content = replace( post_content, '{warningbox}', '{salong-message style="warning" icon="1"}' )
搜索:{errorbox}
,替换为:{salong-message style="error" icon="1"}
,选择『wp_post
』表
// SQL语句: update wp_posts set post_content = replace( post_content, '{errorbox}', '{salong-error style="info" icon="1"}' )
分别搜索:{/infobox}
,{/successbox}
,{/warningbox}
,{/errorbox}
,替换为:{/salong-message}
,选择『wp_posts
』表
// SQL语句: update wp_posts set post_content = replace( post_content, '{/infobox}', '{/salong-message}' ) update wp_posts set post_content = replace( post_content, '{/successbox}', '{/salong-message}' ) update wp_posts set post_content = replace( post_content, '{/warningbox}', '{/salong-message}' ) update wp_posts set post_content = replace( post_content, '{/errorbox}', '{/salong-message}' )
2、按钮
按钮简码的结构变化完全不一样,选项也较多,要搜索替换相对麻烦,只能单个查找并重新设置
3、视频
搜索:{youku
,替换为:{youku-video
,选择『wp_posts
』表;搜索:{/youku}
,替换为:{/youku-video}
,选择『wp_posts
』表
// SQL语句: update wp_posts set post_content = replace( post_content, '{youku', '{youku-video' ) update wp_posts set post_content = replace( post_content, '{/youku}', '{/youku-videoe}' )
搜索:qqvideo
,替换为:qq-video
,选择『wp_posts
』表;搜索:qqvideo_id
,替换为:qq_id
,选择『wp_posts
』表
// SQL语句: update wp_posts set post_content = replace( post_content, 'qqvideo', 'qq-video' ) update wp_posts set post_content = replace( post_content, 'qqvideo_id', 'qq_id' )
搜索:sl_video
,替换为:html5-video
,选择『wp_posts
』表
// SQL语句: update wp_posts set post_content = replace( post_content, 'sl_video', 'html5-video' )
搜索:sl_audio
,替换为:html5-audio
,选择『wp_posts
』表
// SQL语句: update wp_posts set post_content = replace( post_content, 'sl_audio', 'html5-audio' )
4、标签文章
搜索:related_posts
,替换为:tag-posts
,选择『wp_posts
』表
// SQL语句: update wp_posts set post_content = replace( post_content, 'related_posts', 'tag-posts' )
5、内容可见
请将{
替换为{
搜索:{reply}
,替换为:{comment-visible}
,选择『wp_posts
』表;搜索:{/reply}
,替换为:{/comment-visible}
,选择『wp_posts
』表
// SQL语句: update wp_posts set post_content = replace( post_content, '{reply}', '{comment-visible}' ) update wp_posts set post_content = replace( post_content, '{/reply}', '{/comment-visible}' )
搜索:{private}
,替换为:{login-visible}
,选择『wp_posts
』表;搜索:{/private}
,替换为:{/login-visible}
,选择『wp_posts
』表
// SQL语句: update wp_posts set post_content = replace( post_content, '{private}', '{login-visible}' ) update wp_posts set post_content = replace( post_content, '{/private}', '{/login-visible}' )
搜索:{role}
,替换为:{role-visible}
,选择『wp_posts
』表;搜索:{/role}
,替换为:{/role-visible}
,选择『wp_posts
』表
// SQL语句: update wp_posts set post_content = replace( post_content, '{role}', '{role-visible}' ) update wp_posts set post_content = replace( post_content, '{/role}', '{/role-visible}' )
新增了等级和积分可见,购买可见需要重新设置,之前是通过购买产品,现在可直接付费。
三、修改文章 ID 字段
新版的数据结构和旧版的不一样,所以有些字段的数组需要重组下,才能正常显示。
1、更新文章专题 ID 字段
/*更新文章专题 ID 字段 */
$post_args = get_posts(array(
'posts_per_page' => -1,
'post_type' => 'post',
));
foreach ($post_args as $post) {
$new_post_topic_id = get_post_meta($post->ID, 'new_post_topic_id', true);
if (!$new_post_topic_id) continue;
$belong_topics = [];
foreach ($new_post_topic_id as $key => $value) {
$belong_topics[] = trim($value);
}
update_post_meta($post->ID, 'belong_topics', $belong_topics);
// 删除旧的字段
delete_post_meta($post->ID, 'new_post_topic_id');
}
2、更新专题文章 ID 字段
/* 更新专题文章 ID 字段 */ $topic_args = get_posts(array( 'posts_per_page' => -1, 'post_type' => 'topic', )); foreach ($topic_args as $post) { $new_topic_post_id = get_post_meta($post->ID, 'new_topic_post_id', true); if (!$new_topic_post_id) continue; $topic_posts = []; foreach ($new_topic_post_id as $key => $value) { $topic_posts[] = trim($value); } update_post_meta($post->ID, 'topic_posts', $topic_posts); // 删除旧的字段 delete_post_meta($post->ID, 'new_topic_post_id'); }
3、将用户关注数据是对象的转换成数组
/* 将用户关注数据是对象的转换成数组,两个值:following, follower */
$user_args = get_users(array(
'meta_key' => 'following',
));
foreach ($user_args as $user) {
$following = get_user_meta($user->ID, 'following', true);
if (!$following) continue;
$following = [];
foreach ($following as $key => $value) {
$following[] = $value;
}
update_user_meta($user->ID, 'following', $following);
}
4、将视频时间转换成数字,并添加到新字段中,为了视频按时长排序
/*将视频时间转换成时间戳,并添加到新字段中*/
$video_args = get_posts(array(
'posts_per_page' => -1,
'post_type' => 'video',
));
foreach ($video_args as $post) {
$duration = get_post_meta($post->ID, 'duration', true);
if (!$duration) continue;
$duration = str_replace([':', ':'], '', $duration);
update_post_meta($post->ID, 'timestamp', $duration);
}
将如上代码添加到主题根目录下的 functions.php 文件的最后,前台刷新页面,修改后需要在 phpmyadmin 面板中优化和修复下数据库,最后重启服务器或者清除浏览器缓存,才能选择上所有的。