Узнать Id страницы

Необходимо узнать ID страницы (page), которая является родительской для текущей и находится на втором уровне иерархии, то есть следующая после home. Если же эта страница и есть текущей, также возвращать ее ID.
Подскажите пожалуйста, как это реализовать…

Извиняюсь за создание темы не в том месте, перенесите пожалуйста :rolleyes:

Проблема решена.
Нашел функцию, которая забивает в массив ID родительских и прародительских страниц.
Может, кому-то пригодится:
[code- /** get_ancestor_ids
* get an array of ancestor ids for a given page
* you get an array that looks something like
* [0] this page id
* [1] parent page id
* [2] grandparent page id
* @param int page you want the ancestry of
* @param boolean include this page in the tree (optional, default true)
* @param boolean results top down (optional, default true)
* @return an array of ancestor ids
*/
function get_ancestor_ids ( $child = 0, $inclusive=true, $topdown=true ) {
if ( $child && $inclusive ) $ancestors
= $child;
while ($parent = get_parent_id ( $child ) ) {
$ancestors- = $parent;
$child = $parent;
}
// If there are ancestors, test for resorting, and apply
if ($ancestors && $topdown) krsort($ancestors);
if ( !$ancestors ) $ancestors
= 0;
//
return $ancestors;
}[/code]

Anonymous
Отправить
Ответ на: