为了在单个页面模板上显示post类型的元数据,我假设您在循环中。
// Use get_the_ID() to get the ID via the API function
echo get_post_meta( get_the_ID(), \'my-info\', true );
// You can also call it from the global, as the query refers to the current single page
echo get_post_meta( $GLOBALS[\'post\']->ID, \'my-info\', true );
如果没有获得任何输出,则可能需要检查完整的post自定义数据集:
printf( \'<pre>%s</pre>\', var_export( get_post_custom( get_the_ID() ), true ) );