How get current page child?

Sometimes it happens that working with WordPress, we need to get children off current page. There is a fairly simple decision to do this. We can use the WordPress function get_pages (). Here is the code example of how this can be done.

<? $pages = get_pages('child_of='.$post->ID.'&sort_column=post_title');
		?>
		<ul><?
		foreach($pages as $page)
		{ ?>
			<li class="page_item"><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></li>
		<?php
		}
?></ul>

In this example we get page title and page link.

1 comment

Leave a Reply

Your email address will not be published. Required fields are marked *

2 × three =