这个plugin 使用添加内容the_content
优先级较低的筛选器:100。
因此,您可以创建一个输出元字段的函数,并使用具有更高优先级的相同过滤器,即使是标准的20优先级也很好。
function my_post_custom_data( $content ) {
if ( ! is_single() ) return;
global $post;
// here go the code that retrieve and append the custom field to the content
// following is just an example
$mydata = \'\';
$a_field = get_post_meta($post->ID, \'a_key\', true) ? : \'\';
$another_field = get_post_meta($post->ID, \'another_key\', true) ? : \'\';
if ($a_field) $mydata .= \'<li>A key: \' . $a_field . \'</li>\';
if ($another_field) $mydata .= \'<li>Another key: \' . $another_field. \'</li>\';
$mydata = ($a_field || $another_field) ? \'<div class="myfields"><ul>\' . $mydata . \'</ul></div>\' : \'\';
// don\'t forget to return, at least, the content...
return $content . $mydata;
}
add_filter(\'the_content\', \'my_post_custom_data\');