WordPress的自定义域(custom fields),也译作 自定义字段,是一个非常好的功能,你可以通过 自定义域 将自定义的数据写入数据库,然后在需要显示的地方调用出来。这样就增强了主题的可用性和灵活度。
WordPress 3.4.2 发布随即而来的一个明显的Bug就是:自定义域无法在后台正常操作了,对于使用了自定义域的朋友来说,是个比较纠结的问题。解决这个问题的可以使用插件或者添加代码实现。
插件法
下载安装这个插件,激活即可:https://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已经出来,相信正式版快啦!
为什么我的还是没解决呢 😥
这是个很头疼的事情,我是通过修改数据库来变更的! 😮
我一直用WLW,所以没注意这个问题