If you are not using multiple key & values, I’d try it this way
// 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
}
Also you can use the_content filter to add anything to single.php
Example code:
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');