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所有 。
翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-show-hidden-custom-fields-in-wordpress/