<?php $children = get_pages(array('child_of' => $post->ID));
foreach ($children as $child) { ?>
<div class="small-12 medium-6 large-6 columns end">
<fieldset data-equalizer-watch>
<h3><a href="<?php echo get_permalink($child->ID); ?>"><?php echo $child->post_title; ?></a></h3>
<?php echo get_the_post_thumbnail($child->ID, array(50,50)); ?>
<p><?php echo $child->post_excerpt; ?></p>
<a href="<?php echo get_permalink($child->ID); ?>">Read More...</a>
</fieldset>
</div>
<?php } ?>
]]>I have a page that has 4 child pages. On this top page I want to have the 4 child pages as titled sections and beneath each child page title, display a list of links for all (grand)child pages of that section.
So like this:
Child One
-child one child
-child one child
-child one child
Child Two
-child two child
-child two child
-child two child
Child Three
-child three child
-child three child
-child three child
Child Four
-child four child
-child four child
-child four child
I know how to display child pages of the current page but I want to have 4 separate child page lists on the same top level page called by ID of their parents.
Please can anyone advise me on how to achieve this?
Thanks!
]]>I want to create a function which will take all pages with a specific name e.g. Events. Then if the template is not set to e.g. ‘my-template.php’ then set it/change it.
Im new to coding and have found that i can get the pages by using:
$page = get_page_by_title( 'Events' );
Im guessing i can set the page template with:
update_post_meta( $page, '_wp_page_template', 'my-template.php' );
Do I need to pull the ID’s for all pages with a certain title somehow? possibly into a foreach page function?
Thanks
Nick
]]><?php $tier1 = get_pages('hierarchical=0&parent=8&sort_column=menu_order');
foreach ( $tier1 as $page ) { ?>
<div class="tier_unit">1</div>
<div class="tier1">
<div class="tier_title">
<?php echo $page->post_title; ?>
</div>
<div class="page_type">
<img src="/wp-content/uploads/<?php the_field('page_type',$page->ID); ?>.jpg" />
</div>
</div>
<?php $tier2 = get_pages('hierarchical=0&parent='.$page->ID.'&sort_column=menu_order');
foreach ( $tier2 as $page ) { ?>
<div class="tier_unit">2</div>
<div class="tier2">
<div class="tier_title">
<?php echo $page->post_title; ?>
</div>
<div class="page_type">
<img src="/wp-content/uploads/<?php the_field('page_type',$page->ID); ?>.jpg" />
</div>
</div>
<?php $tier3 = get_pages('hierarchical=0&parent='.$page->ID.'&sort_column=menu_order');
foreach ( $tier3 as $page ) { ?>
<div class="tier_unit">3</div>
<div class="tier3">
<div class="tier_title">
<?php echo $page->post_title; ?>
</div>
<div class="page_type">
<img src="/wp-content/uploads/<?php the_field('page_type',$page->ID); ?>.jpg" />
</div>
</div>
<?php $tier4 = get_pages('hierarchical=0&parent='.$page->ID.'&sort_column=menu_order');
foreach ( $tier4 as $page ) { ?>
<div class="tier_unit">4</div>
<div class="tier4">
<div class="tier_title">
<?php echo $page->post_title; ?>
</div>
<div class="page_type">
<img src="/wp-content/uploads/<?php the_field('page_type',$page->ID); ?>.jpg" />
</div>
</div>
<?php $tier5 = get_pages('hierarchical=0&parent='.$page->ID.'&sort_column=menu_order');
foreach ( $tier5 as $page ) { ?>
<div class="tier_unit">5</div>
<div class="tier5">
<div class="tier_title">
<?php echo $page->post_title; ?>
</div>
<div class="page_type">
<img src="/wp-content/uploads/<?php the_field('page_type',$page->ID); ?>.jpg" />
</div>
</div>
<?php $tier6 = get_pages('hierarchical=0&parent='.$page->ID.'&sort_column=menu_order');
foreach ( $tier6 as $page ) { ?>
<div class="tier_unit">6</div>
<div class="tier6">
<div class="tier_title">
<?php echo $page->post_title; ?>
</div>
<div class="page_type">
<img src="/wp-content/uploads/<?php the_field('page_type',$page->ID); ?>.jpg" />
</div>
</div>
<?php $tier7 = get_pages('hierarchical=0&parent='.$page->ID.'&sort_column=menu_order');
foreach ( $tier7 as $page ) { ?>
<div class="tier_unit">7</div>
<div class="tier7">
<div class="tier_title">
<?php echo $page->post_title; ?>
</div>
<div class="page_type">
<img src="/wp-content/uploads/<?php the_field('page_type',$page->ID); ?>.jpg" />
</div>
</div>
<?php } //Tier 7 ?>
<?php } //Tier 6 ?>
<?php } //Tier 5 ?>
<?php } //Tier 4 ?>
<?php } //Tier 3 ?>
<?php } //Tier 2 ?>
<?php } //Tier 1 ?>
]]>At the moment I have this:
<?php
$children = get_pages('child_of=' . $post->ID);
if (!empty($children)) {
foreach($children as $child) {
$tittel = get_the_title($child->ID);
$dato = get_post_meta($child->ID, 'dato', true);
$regiss?r= get_post_meta($child->ID, 'regiss?r', true);
$nasjonalitet= get_post_meta($child->ID, 'nasjonalitet', true);
$produksjons?r= get_post_meta($child->ID, 'produksjons?r', true);
$klokkeslett= get_post_meta($child->ID, 'klokkeslett', true);
$url= get_permalink($child->ID);
echo '<p><strong>' . strtoupper(date("l, j. F", strtotime($dato))) . ', KL. ' . $klokkeslett . '</strong><br>';
echo '<a href="' . $url . '">' . strtoupper($tittel) . '</a>'; if (!empty($regiss?r)) { echo ' – ' . $regiss?r . ', ' . $nasjonalitet . ', ' . $produksjons?r . '</p>';}
}
}
?>
At the moment, the list is just like I want it, except that the pages are not sorted by the custom field ‘dato’, which is what I’d like to do.
]]>currently all i need now is the function to display and store the selection in my options.php file but right now all i can seem to get out of it is either a standalone list that wont save or a section that wont support a word press generated list of pages.
if anyone can help with the function that would store the selected page inside my options array the way that Otto’s settings API tutorial does that would be incredibly appreciated
]]>I’m using the following code in a table cell to show a list of page excerpts
<?php $pages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=asc');
$count = 0;
foreach($pages as $page)
{
$excerpt = $page->post_excerpt;
if(!$excerpt)
continue;
$excerpt = apply_filters('the_excerpt', $excerpt);
?>
<a href="<?php echo get_page_link($page->ID) ?>"><?php echo $excerpt ?></a>
<?php
}
?>
but rather than just show the subpages of the current page, it will show all subpages.
At the moment it works and only shows direct descendants if I hard code in the page ID, but I’d like to make this a template I can implement onto other pages without having to edit the code each time.
Any ideas?
Cheers
Anthony
I am attempting to have a parent page display $more content + link to full content of all children pages.
I found the following code (below) from here Codex -Function Reference/get pages but it doesn’t quite do what I’m after.
I need help adjusting the below code to:
<?php
$pages = get_pages('child_of=gallery'.$post->ID.'&sort_column=post_date&sort_order=desc');
$count = 0;
$more = 0;
foreach($pages as $page)
{
$content = $page->post_content;
if(!$content)
continue;
if($count >= 2)
break;
$count++;
$content = apply_filters('the_content', $content);
?>
<h3><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></h3>
<?php echo $content ?>
<?php
}
?>
Help would be greatly appreciated.
Cheers
]]>$triplistarray = array();
$tripparent = 2;
$args=array(
'child_of' => $tripparent
);
//$gettrips = get_pages($args);
if ($gettrips) {
foreach($gettrips as $trip) {
setup_postdata($trip);
if ($post->post_parent != $parent ) {
array_push($triplistarray,$post->ID);
}
} // foreach($pages
} // if $pages
the call to get_pages seems to be breaking the front end of the website is there anyway around this?
]]>