解决WordPress 3.0中最新评论失效的问题
版权声明:转载时请以超链接形式标明文章原始出处和作者信息
本文链接:http://www.penddy.com/solve-the-wordpress-3-0-comment-in-the-latest-issue-failure.html
在后台自动把WordPress升级到了3.0,发现博客右侧的"最新评论"失效,一番查找原因,最后解决,大概过程记录如下:
1.经过查看,发现首页最新评论部分调用的为get_recent_comments函数。
2.经过查找,发现此函数来源于盆地使用的模板中的functions.php中
3.经过打印调试日志,发现其中的全局变量$tableposts和$tablecomments失效,从而导致获取最新评论的sql语句失效。
4.经过查找,发下在WordPress3.0中,上述全局变量已经不再存在,包括上述两个变量在内的有变化的全局变量变化如下:
$tableposts (use $wpdb->posts)
$tableusers (use $wpdb->users)
$tablecategories (use $wpdb->categories)
$tablepost2cat (use $wpdb->post2cat)(Gone in ver 2.3 $wpdb->terms)
$tablecomments (use $wpdb->comments)
$tablelinks (use $wpdb->links)
$tablelinkcategories (does not exist – all categories are in the main categories table now, and there is not a separate link categories table)
$tableoptions (use $wpdb->options)
$tablepostmeta (use $wpdb->postmeta)
5.替换$tableposts为$wpdb->posts,替换$tablecomments为$wpdb->comments,此问题即解决。
(完)
相关文章
标签: WordPress
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!