我正在尝试使用此更新functions.php,这是直接从网站上的Attachments插件复制的代码,但我收到T_DOUBLE_ARROW语法错误,任何想法为什么? : -
<?php
function my_attachments( $attachments )
{
$fields => array(
array(
'name' => 'title', // unique field name
'type' => 'text', // registered field type
'label' => __( 'Title', 'attachments' ), // label to display
'default' => 'title', // default value upon selection
),
array(
'name' => 'caption', // unique field name
'type' => 'textarea', // registered field type
'label' => __( 'Caption', 'attachments' ), // label to display
'default' => 'caption', // default value upon selection
),
);
$args = array(
// title of the meta box (string)
'label' => 'My Attachments',
// all post types to utilize (string|array)
'post_type' => array( 'post', 'page' ),
// meta box position (string) (normal, side or advanced)
'position' => 'normal',
// meta box priority (string) (high, default, low, core)
'priority' => 'high',
// allowed file type(s) (array) (image|video|text|audio|application)
'filetype' => null, // no filetype limit
// include a note within the meta box (string)
'note' => 'Attach files here!',
// text for 'Attach' button in meta box (string)
'button_text' => __( 'Attach Files', 'attachments' ),
// text for modal 'Attach' button (string)
'modal_text' => __( 'Attach', 'attachments' ),
// which tab should be the default in the modal (string) (browse|upload)
'router' => 'browse',
// fields array
'fields' => $fields,
);
$attachments->register( 'my_attachments', $args ); // unique instance name
}
add_action( 'attachments_register', 'my_attachments' );
&GT;
答案 0 :(得分:5)
应该是
$fields = array(...
而不是
$fields => array(