如何在WordPress中显示隐藏的自定义字段

Often when a plugin needs to utilize custom fields and work in the background, the authors make them hidden by adding an underscore to the name. This allows their plugin to work smoothly without any interruption. But if you are a developer trying to debug something or just a curious learner, then you probably want to know everything that is being added by the plugins. In this article, we will show you how you can display hidden custom fields in WordPress.

通常,当插件需要利用自定义字段并在后台工作时,作者会在名称中添加下划线以使其隐藏。 这样一来,他们的插件即可顺利运行,而不会受到任何干扰。 但是,如果您是尝试调试某些东西的开发人员,或者只是一个好奇的学习者,那么您可能想知道插件所添加的所有内容。 在本文中,我们将向您展示如何在WordPress中显示隐藏的自定义字段。

All you need to do is open your theme’s functions.php file and drop this code in there:

您所需要做的就是打开主题的functions.php文件,并将此代码放在那里:

add_action( 'admin_head', 'showhiddencustomfields' );

function showhiddencustomfields() {
	echo "<style type='text/css'>#postcustom .hidden { display: table-row; }</style>
";
}

However by pasting the code, you are limited to the specific theme. If you wanted to switch the theme, then you would have to add this code all over again. So you can simply create a PHP file, and save the code in there and upload it as a plugin.

但是,通过粘贴代码,您只能使用特定的主题。 如果要切换主题,则必须重新添加此代码。 因此,您只需创建一个PHP文件,然后将代码保存在其中,然后将其作为插件上传即可。

Or you can simply use Show Hidden Custom Fields

或者,您可以简单地使用“ 显示隐藏的自定义字段”

All credits for this amazing trick goes to Viper007Bond.

此神奇技巧的所有功劳归Viper007Bond所有

flyer printing experts, Next Day Flyers. 传单印刷专家Next Day Flyers提供。

翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-show-hidden-custom-fields-in-wordpress/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值