Npcink Blog
切换菜单

WordPress 主题开发: 制作文章页面 single.php

常用函数

来源于:

https://www.cnblogs.com/tinyphp/p/5940678.html

可以调用的文章内容:

调用文章标题:

调用文章内容:

调用文章摘要:

调用作者姓名:

调用文章发布时间:

调用作者的 Gravatar 头像:

调用文章内容可以写:

<?php echo the_content();?>

或者

<?php while( have_posts() ): the_post(); $p_id = get_the_ID(); ?>
<?php the_content(); ?>
<?php endwhile; ?>

但是这个 WordPress 会自动在段落上加上 p,解决方法可以改为下面的写法

<?php $post=get_post(get_the_ID());
echo $post->post_content;
?>

post_author:(整数)文章作者的编号

post_date:(字符)文章发表的日期和时间(YYYY-MM-DD HH-MM-SS)

post_date_gmt:(字符)文章发表的格林尼治标准时间(GMT) (YYYY-MM-DD HH-MM-SS)

post_content:(字符)文章内容

post_title:(字符)文章标题

post_category:(整数)文章类别的编号。注意:该值在 WordPress 2.1 之后的版本总为 0。定义文章的类别时可使用 get_the_category()函数。

post_excerpt:(字符)文章摘要

post_status:(字符)文章状态(publish|pending|draft|private|static|object|attachment|inherit|future)

comment_status:(字符)评论状态(open|closed|registered_only)

ping_status:(字符)pingback/trackback 状态(open|closed)

post_password:(字符)文章密码

post_name:(字符)文章的 URL 嵌套

to_ping:(字符)要引用的 URL 链接

pinged:(字符)引用过的链接

post_modified:(字符)文章最后修改时间(YYYY-MM-DD HH-MM-SS)

post_modified_gmt:(字符)文章最后修改 GMT 时间(YYYY-MM-DD HH-MM-SS)

post_parent:(整数)父级文章编号(供附件等)

guid:(字符)文章的一个链接。注意:不能将 GUID 作为永久链接(虽然在 2.5 之前的版本中它的确被当作永久链接),也不能将它作为文章的可用链接。GUID 是一种独有的标识符,只是目前恰巧成为文章的一个链接。

post_type:(字符)(日志 | 页面 | 附件)

常用:

发表于: the_time('Y-h-d'); ?>
分类: the_category(','); ?>