<?php
/**
* Template Name: Custom Single Post Template
*
* @package WordPress
* @subpackage YourTheme
*/
get_header(); // 加载头部信息
// 获取当前文章ID
$post_id = get_the_ID();
// 获取文章数据
$post = get_post($post_id);
// 检查是否成功获取文章
if ($post) {
?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h1 class="entry-title"><?php the_title(); ?></h1>
<div class="entry-content">
<?php the_content(); ?>
<?php wp_link_pages(); ?>
</div>
</div>
<?php
} else {
// 如果没有找到文章,显示错误消息
echo '没有找到文章。';
}
get_footer(); // 加载页脚信息
?>