Is there a similar cat_is_ancestor_of function for pages?
reference:
http://codex.wordpress.org/Function_Reference/cat_is_ancestor_of
Is there a similar cat_is_ancestor_of function for pages?
reference:
http://codex.wordpress.org/Function_Reference/cat_is_ancestor_of
Assuming your page object is in $post (like inside a normal post loop):
<?php
if (in_array("95", $post->ancestors)) {
echo "page id 95 is an ancestor of this page";
}
?>I am looking to display a sub-navigation in the sidebar of all the child pages for a parent page. Is this the best way to achieve this?
Could look at some examples using wp_list_pages().
Yes, thank you. :)
Here is my end result for those that come across this thread:
// [not shown] special cases for post categories up here (using is_ancestor_of function)
// now for the pages
elseif(is_page()) {
//get post id
global $post;
$page = $post->ID;
// Some Menu for a set of pages
if($page == "68" || $post->post_parent == "68" ) { ?>
<h3>Some Title For this Set of Pages</h3>
<ul>
<?php wp_list_pages('orderby=name&child_of=68&title_li='); ?>
</ul>
<?php }
// Another Menu for another set of pages
if ($page == '751' || $post->post_parent == "751" ) { ?>
<h3>Some Other Title For this Set of Pages</h3>
<ul>
<?php wp_list_pages('depth=2&child_of=751&title_li='); ?>
</ul>
<?php }
} else { ?>
// standard sidebar stuff for untargeted pages or postsThis topic has been closed to new replies.