• 首页
  • >
  • 修复 WordPress 3.4.2 自定义域无法操作的问题
  • >
  • 正文

修复 WordPress 3.4.2 自定义域无法操作的问题

219次阅读

WordPress的自定义域(custom fields),也译作 自定义字段,是一个非常好的功能,你可以通过 自定义域 将自定义的数据写入数据库,然后在需要显示的地方调用出来。这样就增强了主题的可用性和灵活度。

WordPress 3.4.2 发布随即而来的一个明显的Bug就是:自定义域无法在后台正常操作了,对于使用了自定义域的朋友来说,是个比较纠结的问题。解决这个问题的可以使用插件或者添加代码实现。

插件法

下载安装这个插件,激活即可:http://wordpress.org/extend/plugins/hotfix/

代码法

将下面的代码添加到 functions.php 中即可:

<?php
/*
Plugin Name: Fix Custom Fields in WP 3.4.2
Version: 0.1
Plugin URI: http://core.trac.<a href="http://www.it165.net/edu/ebg/" target="_blank" class="keylink">word</a>press.org/ticket/21829
Description: Implements a workaround for adding and updating custom fields in WordPress 3.4.2.
Author: Sergey Biryukov
Author URI: http://profiles.wordpress.org/sergeybiryukov/
*/
 
function fix_custom_fields_in_wp342() {
        global $wp_version, $hook_suffix;
 
        if ( '3.4.2' == $wp_version && in_array( $hook_suffix, array( 'post.php', 'post-new.php' ) ) ) : ?>
<script type="text/javascript">
jQuery(document).delegate( '#addmetasub, #updatemeta', 'hover focus', function() {
        jQuery(this).attr('id', 'meta-add-submit');
});
</script>
<?php
        endif;
}
add_action( 'admin_print_footer_scripts', 'fix_custom_fields_in_wp342' );
?>

WordPress 3.5 Beta 2已经出来,相信正式版快啦!

作者:管理员  修订  2019/02/01 17:15:35

WP爱好者专注WordPress在线系统培训,10年来超过十万学员在此获得技术提升和人脉圈子。

WordPress课程已融入到移动搜索、零基础建站、WP爱好者开源主题模板、SEM入门等。

欢迎添加助教微信:tc199361,马上获得优秀学员案例。