我设置了一个函数,可以在每个帖子中放置一些标准文本,用于自定义帖子类型。然而,在这个标准文本中,我想从几个自定义字段中提取一些独特的文本。不确定我的代码有什么问题:
function default_content($content) {
global $post;
if ($post->post_type == \'my-custom-post-type\') {
$content .= \'<p style="text-align: center;"><strong>Custom Field Text here: <?php echo get_post_meta( get_the_ID(), \\\'custom-field-1\\\', true )</strong></p>
<p style="text-align: center;"><a href="http://myblog.com/?checkout=<?php echo get_post_meta( get_the_ID(), \\\'custom-field-2\\\', true )">Link 01</a></p>\';
}
return $content;
}
add_filter(\'the_content\', \'default_content\', 0);