【发布时间】:2016-07-03 23:23:12
【问题描述】:
我正在关注this 教程,但到目前为止我所做的并不能正常工作。我已经到了开始使用循环的地步——这是我的代码:
index.php
<?php get_header(); ?>
<div class="row">
<div class="col-sm-8 blog-main">
<?php
if ( have_posts() ) : while ( have_posts() ) : the_post();
get_template_part( 'content', get_post_format() );
endwhile; endif;
?>
</div><!-- /.blog-main -->
<?php get_sidebar(); ?>
</div><!-- /.row -->
<?php get_footer(); ?>
</div><!-- /.container -->`
content.php
<div class="blog-post">
<h2 class="blog-post-title"><?php the_title(); ?></h2>
<p class="blog-post-meta"><?php the_date(); ?><a href="#"><?php the_author(); ?></a></p>
<?php the_content(); ?>
</div><!-- /.blog-post -->
我有两个帖子,但只有最新的帖子被显示(通过循环)并且在显示的帖子中 - 唯一显示的部分是标题。因此,the_date()、the_author() 和 the_content() 函数似乎由于某种原因无法正常工作,并且循环仅获取其中一篇文章(最新一篇)。
怎么了?谢谢。
【问题讨论】:
-
对于帖子显示,请在 WP admin 中更改选项,对于数据和内容查看您的 css 样式。
标签: php html wordpress function loops