WordPress函数get_post()

利用WordPress函数get_post(),可以调用指定ID的文章,获取链接、标题及内容。

post_content; // 输出文章content内容get_the_content( $post_id ); // 输出文章content内容echo get_permalink( $post_id ); //链接URL get_the_title($post_id); //title?>

调取指定问

get_permalink()则比较灵活,可以用在loop循环内,但没有echo打印出来显示在前端;也可以放在循环外,但是如果是在循环外必须加文章id

  1、在循环内,the_permalink()相当于打印出来的get_permalink()

1

  2、在循环外,get_permalink()必须加post id,调用方法如下

1

获取缩略图

其他参数:

post_author :文章作者的编号

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

post_data_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 :(字符)(日志 | 页面 | 附件)

你可能感兴趣的:(Wordpress,php)