Created
October 23, 2013 18:37
-
-
Save barbwiredmedia/7124127 to your computer and use it in GitHub Desktop.
Wordpress Temples: This creates a conditional based on the parent page ID. If ( specific page || checks for existence of having our parent page || looks for all ancestors of our parent and limits it to those children only ) The query brings back posts that are children of our parent.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Set up the variables of the parent page ID's | |
$parentPageID = '509'; | |
?> | |
<?php if (is_page($parentPageID) || $post->post_parent == $parentPageID || ($post->ancestors && in_array($parentPageID, $post->ancestors) )) { ?> | |
<h3>Child Pages</h3> | |
<ul> | |
<?php | |
//Queries for all pages that are children of our parent ID | |
?> | |
<?php | |
query_posts(array('showposts' => 5, 'post_parent' => $parentPageID, 'post_type' => 'page')); | |
while (have_posts()) { | |
the_post(); | |
?> | |
<li><a href="<?php the_permalink() ?>"><?php the_title() ?></a></li> | |
<?php } ?> | |
<?php wp_reset_query(); ?> | |
</ul> | |
<?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment