wordpress输出文章列表

函数

have_posts()函数

描述:判断是否有日志

<?php
if(have_posts()){
    true
}else{
    false
}

the_posts()函数

描述:获取下一篇文章的信息,并将信息存入全局变量$post中

<?php
the_posts();

the_title()函数

描述:获取当前文章的标题

<?php
the_title();

the_permalink()函数

描述:获取当前文章的链接

<?php
the_permalink();

the_content()函数

描述:获取当前文章的文章内容

<?php
the_content();

the_excerpt()函数

描述:显示文章的一部分内容

<?php
the_excert();

the_category()函数

描述:当前文章所属的分类

<?php
the_category( $separator, $parents, $post_id );
$separator			【可选】,指定间隔符号
$parents			【可选】,分类显示方式,两个值multiple和single,multiple显示所有分类,single只显示指定文章ID的父分类
$post_id			【可选】,文章的id    

the_author()函数

描述:当前文章的作者

<?php
the_author();

the_time()函数

描述:获取当前文章的发布时间

<?php
the_time('Y-m-d');

edit_post_link()函数

描述:当登录管理员或者有权限编辑当前文章的时候,显示一个编辑连接,方便修改文章

<?php
edit_post_link( string $text = null, string $before = '', string $after = '', integer $id = 0, string $class = 'post-edit-link');
$text
字符串值,默认为空
链接的锚文本

$before
字符串值,默认为空
在链接前输出的文本

$after
字符串值,默认为空
在链接后输出的文本

$id
整数型,默认值:0
指定文章ID,输出该文章的编辑链接。

$class
字符串值,默认值:post-edit-link
链接的类名

例:edit_post_link('编辑','|');

posts_nav_link()函数

描述:翻页导航链接,用于在分类、标签、日期等归档页显示上一页、下一页

<?php
posts_nav_link(string $sep = '', string $prelabel = '', string $nxtlabel = '');
$sep		【可选】,翻页链接之间显示的字符
$prelabel	【可选】,上一页链接的文本
$nxtlabel	【可选】,下一页链接的文本
posted @ 2021-03-09 19:34  Lcxuan27  阅读(260)  评论(0)    收藏  举报