//Get top ancestor
function get_top_ancestor_id()
{
global $post;
if($post->post_parent)
{
$ancestors = array_reverse(get_post_ancestors($post->ID));
return $ancestors[0];
}
return $post->ID;
}Wordpress get_top_ancestor_id()
最新推荐文章于 2023-07-22 21:14:02 发布
本文介绍了一个用于WordPress的PHP函数,该函数可以返回当前文章的顶级父级ID,如果文章没有父级,则返回自身的ID。此功能对于构建层级结构的内容特别有用。
1284

被折叠的 条评论
为什么被折叠?



