导入
WordPress 循环
了解主题文件的基本组成部分:著名的 WordPress 循环。
...
卓越主题文件夹
have_posts() 函数
1<?php 2while( have_posts() ) { 3 4} 5?>
the_post() 函数
1<?php 2while(have_posts()) { 3 the_post(); 4 5} 6?>
在 PHP 和 HTML 之间切换
1<?php 2while(have_posts()) { 3 the_post(); ?> 4 5<!-- HTML 代码在此处 --> 6 7<?php 8}?>
使用 the_title() 函数显示文章标题
1<?php 2while(have_posts()) { 3 the_post(); ?> 4 5 <h1><?php the_title() ?></h1> 6 7<?php 8} 9?>
...
显示文章标题
使用 the_content() 函数显示文章内容
1<?php 2while(have_posts()) { 3 the_post(); ?> 4 5 <h1><?php the_title() ?></h1> 6 <p><?php the_content() ?></p> 7 <br/><hr/><br/> 8 9<?php 10} 11?>
...
显示文章标题和内容
添加超链接
1<h1><a href=""><?php the_title() ?></a></h1>
the_permalink() 函数
1<h1><a href="<?php the_permalink();?>"><?php the_title() ?></a></h1>
...
将文章标题显示为超链接