【发布时间】:2018-08-06 13:08:45
【问题描述】:
我在 Wordpress 站点中使用 ACF 来配置自定义帖子类型的一些选项,并使用 ACF 唯一 ID 插件生成一个字段,该字段为该字段构建唯一 ID。它的配置非常基础:
class acf_field_unique_id extends acf_field {
function __construct() {
/*
* name (string) Single word, no spaces. Underscores allowed
*/
$this->name = 'unique_id';
/*
* label (string) Multiple words, can include spaces, visible when selecting a field type
*/
$this->label = __('Unique ID', 'acf-unique_id');
/*
* category (string) basic | content | choice | relational | jquery | layout | CUSTOM GROUP NAME
*/
$this->category = 'layout';
/*
* l10n (array) Array of strings that are used in JavaScript. This allows JS strings to be translated in PHP and loaded via:
* var message = acf._e('unique_id', 'error');
*/
$this->l10n = array(
);
// do not delete!
parent::__construct();
}
/*
* render_field()
*
* Create the HTML interface for your field
*
* @param $field (array) the $field being rendered
*
* @type action
* @since 3.6
* @date 23/01/13
*
* @param $field (array) the $field being edited
* @return n/a
*/
function render_field( $field ) {
?>
<input type="text" readonly="readonly" name="<?php echo esc_attr($field['name']) ?>" value="<?php echo esc_attr($field['value']) ?>" />
<?php
}
}
虽然所有这些功能都很好,但 ID 字段被设计为内部 ID 标记,最终用户不需要在 Wordpress 中看到。有没有办法隐藏与该字段关联的列,这样我就不会失去宝贵的屏幕空间?该列占宽度的 33%,并且由于它用于不必要的字段,因此占用了太多空间。我尝试将它隐藏在 CSS 和 Javascript 中,但由于某种原因,这使得结束列(重复行号和 +/- 符号)更大。
【问题讨论】:
标签: wordpress advanced-custom-fields