WordPress怎么通过ID获取文章标题,摘要内容等信息

2025-04-08 23:30:58
推荐回答(1个)
回答1:

get_post函数就可以用来获取指定ID的相关信息

$id = 8;
$post = get_post( $id );
var_dump($post);

如果仅仅只是获取标题,则用get_the_title

get_the_title( $id );

摘要:get_the_excerpt($id);

内容:get_the_content($id);