| Server IP : 159.69.118.108 / Your IP : 216.73.216.200 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ubuntu-4gb-fsn1-1 6.8.0-90-generic #91-Ubuntu SMP PREEMPT_DYNAMIC Tue Nov 18 13:53:54 UTC 2025 aarch64 User : root ( 0) PHP Version : 8.2.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/clients/deborahrobinson.net/wp-content/themes/debbie/ |
Upload File : |
<?php
// Get page by slug.
// https://codex.wordpress.org/Function_Reference/get_page_by_path
// http://wordpress.stackexchange.com/questions/102841/how-to-get-page-id-of-a-page-using-page-slug
$page_slug = 'projects';
$slug_type = 'page';
$output_type = ARRAY_A;
$page = get_page_by_path($page_slug, $output_type, $slug_type);
// // Get all pages belong to a parent.
// // http://wordpress.stackexchange.com/questions/74063/getting-only-direct-child-pages-in-wordpress-with-get-pages
// // https://codex.wordpress.org/Function_Reference/get_pages
// // https://developer.wordpress.org/reference/functions/get_pages/
// $args = array(
// 'child_of' => $page['ID'],
// 'parent ' => $page['ID'],
// 'offset' => 0,
// 'post_type' => 'page',
// 'post_status' => 'publish',
// 'sort_column' => 'menu_order',
// 'sort_order' => 'asc',
// );
// $pages = get_pages($args);
// Get all pages belong to a parent.
// https://codex.wordpress.org/Function_Reference/get_children
// http://stackoverflow.com/questions/6137559/wordpress-limit-get-pages-to-show-5-items
// https://wordpress.org/support/topic/sort-children-by-menu-order
$output_type = ARRAY_A;
$output_type = OBJECT;
$max_items = 6;
$args = array(
'numberposts' => $max_items,
'order' => 'DESC',
'orderby' => 'menu_order',
'post_parent' => $page['ID'],
'post_status' => 'publish',
'post_type' => 'page',
);
$pages = get_children($args, $output_type);
// Get all children and count them.
$children = get_pages('child_of=' . $page['ID']);
?>
<!-- side-box -->
<div class="col-md-3 side-box">
<?php if (count($pages) > 0) { ?>
<h2>PROJECTS</h2>
<ul>
<?php foreach ($pages as $key => $child) { ?>
<li>
<div class="col-md-5 col-sm-3 col-xs-3 project-thumbnail-box">
<a class="pull-left project-thumbnail transparent-onhover" href="<?php echo get_permalink($child->ID); ?>">
<?php if (get_the_post_thumbnail($child->ID, 'thumbnail')) { ?>
<?php
// Get custom featured image size.
// http://stackoverflow.com/questions/9500928/wordpress-custom-featured-image-size
// echo get_the_post_thumbnail($child->ID, 'post-thumbnails', array('class' => 'img-responsive'));
// Get thumbnail size.
echo get_the_post_thumbnail($child->ID, 'thumbnail', array('class' => 'img-responsive'));
?>
<?php } else { ?>
<img src="http://placehold.it/500x600" class="img-responsive" alt="<?php the_title(); ?>" />
<?php } ?>
</a>
</div>
<div class="col-md-7 col-sm-9 col-xs-9 project-title-box">
<a class="project-title" href="<?php echo get_permalink($child->ID); ?>"><?php echo $child->post_title; ?></a>
</div>
</li>
<?php } ?>
</ul>
<?php
if (count($children) > $max_items) {
// Get a random page.
// https://wordpress.org/support/topic/how-to-get-a-single-random-sub-page
shuffle($children);
if ($children) {
$pageids = array();
foreach ($children as $page) {
$pageids[]= $page->ID;
}
}
?>
<a href="<?php echo get_permalink($page->ID); ?>" class="button-more">More »</a>
<?php } ?>
<?php } ?>
</div>
<!-- side-box -->