php技术博客
让天下没有搞不定的bug~

WordPress通过文章标题获取文章 ID 、时间、内容等 post 信息

//格式
get_page_by_title( string $page_title, string $output = OBJECT, string|array $post_type = 'page' )
 
$page_title 页面标题
$output 返回的类型格式,例如 OBJECT,ARRAY_A 或 ARRAY_N 选一个,默认是 OBJECT
$post_type 文章类型,默认为 page 页面,查询文章为 post
 
//WordPress 通过文章标题获取 post 信息
$post = get_page_by_title('这里就是文章的标题', OBJECT, 'post');
$postid = $post->ID; //文章 ID


ID          int     文章 ID
post_author     string  作者 user ID
post_name   string  文章别名
post_type   string  文章类型
post_title  string  文章标题
post_date   string  文章时间,格式为: 0000-00-00 00:00:00
post_date_gmt   string 文章 gmt 时间,格式为,: 0000-00-00 00:00:00
post_content    string  文章内容
post_excerpt    string  文章摘要
post_status     string  文章状态
comment_status  string  评论状态,开启或者关闭: { open, closed }
ping_status     string  ping 状态 { open, closed }
post_password   string  文章密码
post_parent     int     父 ID,默认是 0
post_modified   string  文章修改时间,格式为: 0000-00-00 00:00:00
post_modified_gmt   string  文章修改时间,格式为: 0000-00-00 00:00:00
comment_count   string  文章评论统计
menu_order  string  好像没什么用,默认是 0
赞(0)
未经允许不得转载:PHP技术博客 » WordPress通过文章标题获取文章 ID 、时间、内容等 post 信息