如果你对该文章中的内容有疑问/不解,可以点击此处链接提问
要注明问题和此文章链接地址 点击此处跳转
列表中循环的使用
<!-- 循环 -->
<?php
if(have_posts()){
while (have_posts()){
the_post();
// var_dump($post->ID);
// var_dump($post->post_date);
// var_dump($post->post_title);
?>
<div style='border:1px solid #ccc'>
<h2><a href="<? the_permalink();?>"><? the_title(); ?></a></h2>
<p><? the_content(); ?></p>
</div>
<?php
}
}else{
echo '没有文章显示';
}
?>
判断是否有文章 have_posts()
赋值item the_post()
输出标题 the_title()
输出链接 the_permalink()
输出内容 the_content()
这里输出内容有个小技巧,默认全部全部输出内容,不易截取,可以再编辑器中添加more

前台页面显示

> 本文由子枫笔记快捷发布!
王明昌博客
