我正在使用Wordpress创建一个包含许多自定义页面模板的网站。我使用html5blank作为父主题。我需要将页面内容从文本文件移动到Wordpress页面,以便可以在CMS中进行编辑,但我不确定如何为代码创建正确的循环/模板标记。
这是一个页面示例 -
模板meettheteam.php
<?php /* Template Name: Meet the team */ ?>
<?php get_header(); ?>
<section id="team">
<div class="container">
<div class="twelve columns">
<h4>MEET THE TEAM</h4>
<div class="row">
<div class="four columns">
<img src="http://localhost:8888/wp-content/uploads/2017/07/tim.jpg" alt="Meet Tim" style="width:100px;height:100px;">
<p>Praesent sodales, leo at pellentesque pellentesque, nunc erat dapibus nunc, ut congue libero lorem in orci. Suspendisse potenti. Quisque facilisis mauris in vestibulum tempor.</br>Praesent sodales, leo at pellentesque pellentesque, nunc erat dapibus nunc, ut congue libero lorem in orci. Suspendisse potenti. Quisque facilisis mauris in vestibulum tempor.
</p>
</div>
<div class="four columns">
<img src="http://localhost:8888/wp-content/uploads/2017/07/tim.jpg" alt="Meet Tim" style="width:100px;height:100px;">
<p>Praesent sodales, leo at pellentesque pellentesque, nunc erat dapibus nunc, ut congue libero lorem in orci. Suspendisse potenti. Quisque facilisis mauris in vestibulum tempor.</br>Praesent sodales, leo at pellentesque pellentesque, nunc erat dapibus nunc, ut congue libero lorem in orci. Suspendisse potenti. Quisque facilisis mauris in vestibulum tempor.
</p>
</div>
<div class="four columns">
<img src="http://localhost:8888/wp-content/uploads/2017/07/tim.jpg" alt="Meet Tim" style="width:100px;height:100px;">
<p>Praesent sodales, leo at pellentesque pellentesque, nunc erat dapibus nunc, ut congue libero lorem in orci. Suspendisse potenti. Quisque facilisis mauris in vestibulum tempor.</br>Praesent sodales, leo at pellentesque pellentesque, nunc erat dapibus nunc, ut congue libero lorem in orci. Suspendisse potenti. Quisque facilisis mauris in vestibulum tempor.</p>
</div>
</div>
<div class="row">
<div class="four columns">
<img src="http://localhost:8888/wp-content/uploads/2017/07/tim.jpg" alt="Meet Tim" style="width:100px;height:100px;">
<p>Praesent sodales, leo at pellentesque pellentesque, nunc erat dapibus nunc, ut congue libero lorem in orci. Suspendisse potenti. Quisque facilisis mauris in vestibulum tempor.</br>Praesent sodales, leo at pellentesque pellentesque, nunc erat dapibus nunc, ut congue libero lorem in orci. Suspendisse potenti. Quisque facilisis mauris in vestibulum tempor.</p>
</div>
<div class="four columns">
<img src="http://localhost:8888/wp-content/uploads/2017/07/tim.jpg" alt="Meet Tim" style="width:100px;height:100px;">
<p>Praesent sodales, leo at pellentesque pellentesque, nunc erat dapibus nunc, ut congue libero lorem in orci. Suspendisse potenti. Quisque facilisis mauris in vestibulum tempor.</br>Praesent sodales, leo at pellentesque pellentesque, nunc erat dapibus nunc, ut congue libero lorem in orci. Suspendisse potenti. Quisque facilisis mauris in vestibulum tempor.</p>
</div>
<div class="four columns">
<img src="http://localhost:8888/wp-content/uploads/2017/07/tim.jpg" alt="Meet Tim" style="width:100px;height:100px;">
<p>Praesent sodales, leo at pellentesque pellentesque, nunc erat dapibus nunc, ut congue libero lorem in orci. Suspendisse potenti. Quisque facilisis mauris in vestibulum tempor.</br>Praesent sodales, leo at pellentesque pellentesque, nunc erat dapibus nunc, ut congue libero lorem in orci. Suspendisse potenti. Quisque facilisis mauris in vestibulum tempor.</p>
</div>
</div>
</div>
</div>
</section>
<?php get_template_part('form'); ?>
<?php the_content(); ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
所有<section id="team">
都需要在要编辑的页面上可用。我是否在节标签之间创建“循环”,如下所示 -
<?php
if (have_posts()):
while (have_posts()) : the_post();
the_content();
endwhile;
else:
echo '<p>Sorry, no posts matched your criteria.</p>';
endif;
或者有更简单的方法吗?我是Wordpress的新手,我最初假设所有这些都是通过使用<?php the_content(); ?>
来处理的,但显然不是。我确信这有一个简单的答案,任何帮助都表示赞赏。