我假设您使用了插件“Meta-Box”。如果您尝试使用这一行(例如亚马逊附属公司),它实际上应该可以很好地工作,只需替换$bookID
使用您的ID或获取\\u ID():
echo get_post_meta( $bookID, \'rw_amz\', true );
哦,我刚看到你打开了两个
array
定义字段时,正确的代码应为:
add_action( \'admin_init\', \'rw_register_meta_boxes\' );
function rw_register_meta_boxes() {
$prefix = \'rw_\';
$meta_boxes = array();
// Here is the code to define a meta box
$meta_boxes[] = array(
\'title\' => \'Amazon Affiliate Link\',
\'pages\' => array( \'books\' ),
\'fields\' => array(
\'name\' => \'url\',
\'id\' => $prefix . \'amz\',
\'type\' => \'text\',
)
);
$meta_boxes[] = array(
\'title\' => \'Subtitle\',
\'pages\' => array( \'books\' ),
\'fields\' => array(
\'name\' => \'Subtitle\',
\'id\' => $prefix . \'subt\',
\'type\' => \'text\',
)
);
foreach ( $meta_boxes as $meta_box ) {
new RW_Meta_Box( $meta_box );
}
}