如何获取附件文章类型的字段 get_post_field函数详解

这篇文章的用法可以和image_collection模块的用法紧密结合,每个上传的附件都成为了一个单独的文章,可以获取到文章的标题,内容,描述,附件地址,等等

$uploaded_time = get_post_field('post_date', $attachment_id);

附件文章类型也是文章类型,适用默认的获取文章类型的方法,比方说get_the_title 等

但是content的话 要用到get_post_field 函数,

获取到附件类型的标题是get_the_title(附件的id )

获取到附件的描述是 get_post_field(‘post_content”, 附件id)

如果要获取到附件的caption的值的话,用wp_get_attachment_caption($attachment_id); 函数,

用get_post_field可以获取到的字段有:

ID
post_author
post_date
post_date_gmt
post_content
post_title
post_excerpt
post_status
comment_status
ping_status
post_password
post_name
to_ping
pinged
post_modified
post_modified_gmt
post_content_filtered
post_parent
guid
menu_order
post_type
post_mime_type
comment_count
filter

×
如何获取附件文章类型的字段 get_post_field函数详解

如何获取附件文章类型的字段 get_post_field函数详解

这篇文章的用法可以和image_coll...