[英]Loop in WordPress Page not working
這是我的頁面模板:
它不是在拉內容。不確定我缺少什么嗎?
<?php get_header(); ?>
<section id="services">
<div class="container">
<div class="row divide">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php endwhile; endif; ?>
</div>
</div>
</section>
<?php get_footer(); ?>
此代碼用於顯示模板中的帖子列表。 請嘗試一下。
get_header();
?>
<section id="services">
<div class="container">
<div class="row divide">
<?php
$args = array('post_type' => 'post');
$postlist = new WP_Query($args);
if ($postlist->have_posts()) {
while ($postlist->have_posts()) {
$postlist->the_post();
the_title();
the_content();
// list posts here
}
// post pagination
} else {
// no posts content
}
?>
</div>
</div>
</section>
<?php get_footer();
嘗試
<?php get_header(); ?>
<section id="services">
<div class="container">
<div class="row divide">
<?php if ( have_posts() ) {
while ( have_posts() ) {
the_post();
//
// Post Content here
//
} // end while
} // end if
?>
</div>
</div>
</section>
<?php get_footer(); ?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.