如果未使用多个键(&A);价值观,我会这样尝试
// This function adds a meta box with a callback function of my_metabox_callback()
function add_my_meta_box() {
$var1 = \'this\';
$var2 = \'that\';
add_meta_box(
\'metabox_id\',
\'Metabox Title\',
\'my_metabox_callback\',
\'page\',
\'normal\',
\'low\',
array( \'foo\' => $var1, \'bar\' => $var2)
);
}
// $post is an object containing the current post (as a $post object)
// $metabox is an array with metabox id, title, callback, and args elements.
// The args element is an array containing your passed $callback_args variables.
function my_metabox_callback ( $post, $metabox ) {
echo \'Last Modified: \' . $post->post_modified; // outputs last time the post was modified
echo $metabox[\'args\'][\'foo\']; // outputs \'this\'
echo $metabox[\'args\'][\'bar\']; // outputs \'that\'
echo get_post_meta( $post->ID, \'my_custom_field\', true ); // outputs value of custom field
}
您还可以使用\\u内容过滤器向single添加任何内容。php
示例代码:
function tsi_source_link($content) {
if ( is_single() ) {
global $post;
$source_link = get_post_meta ($post->ID, \'syndication_permalink\', true);
if ($source_link) {
$content .= \'<div id="tsi-source-link" style="text-align:right;"><a href="\' . $source_link . \'" target="_blank">Read more ...</a></div>\';
}
}
return $content;
}
add_action(\'the_content\',\'tsi_source_link\');