所以我第一次尝试创建wordpress页面模板。我创建了一个。包含以下内容的php文件:
<?php
/*
Template Name: Download Page Template
*/
?>
然后,我在页面编辑器中创建了一个页面,并将其指定为使用“下载页面模板”。然而,当我预览这个页面时,我看到的只是主页/索引页。。。我试了几样the codex, 但所发生的一切是,我在wp编辑器中的内容显示在索引页面的最底部。我是否遗漏了一些明显的东西?
所以我第一次尝试创建wordpress页面模板。我创建了一个。包含以下内容的php文件:
<?php
/*
Template Name: Download Page Template
*/
?>
然后,我在页面编辑器中创建了一个页面,并将其指定为使用“下载页面模板”。然而,当我预览这个页面时,我看到的只是主页/索引页。。。我试了几样the codex, 但所发生的一切是,我在wp编辑器中的内容显示在索引页面的最底部。我是否遗漏了一些明显的东西?
如果您上面发布的代码是您的所有文件内容,那么是的,您丢失了一些东西!
您刚刚创建了一个新的页面模板,但它是空的,您需要告诉WordPress要显示什么,通常使用the loop 还有一些其他模板标记将此代码添加到您已有的a.php下:
//this will include the theme header.php file
<?php get_header(); ?>
<div id="content" class="widecolumn">
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<div class="post">
<h2 id="post-<?php the_ID(); ?>"><?php the_title();?></h2>
<div class="entrytext">
<?php the_content(); ?>
</div>
</div>
<?php endwhile; endif; ?>
<?php edit_post_link(\'Edit this entry.\', \'<p>\', \'</p>\'); ?>
</div>
//this will include the theme footer.php file
<?php get_footer(); ?>