Я взял этот код из кодекса Wordpress, который отображает дочерние страницы текущей страницы в формате записи.
Я создал страницу с именем "Домой" и назначил ей шаблон с именем Front Page :
передний page.php:
<?php
/**
* Template Name: Front Page
* @package WordPress
* @subpackage Twenty_Ten
* @since Twenty Ten 1.0
*/
get_header(); ?>
<div id="intro">
<div id="tagline">
<?php // Retrieve a list of latest posts or post(s) matching criteria).
$args = array('category_name' => 'Tagline', 'numberposts' => 1, 'order' => 'DESC');
$customposts = get_posts($args);
foreach($customposts as $post) : setup_postdata($post); ?>
<h2 class="entry-title"><?php the_title(); ?></h2>
<div class="entry-content">
<?php the_content(); ?>
</div>
<?php endforeach; ?>
</div><!-- #tagline -->
<div id="featured">
<img src="<?php bloginfo('template_directory'); ?>/images/<?php echo get_option(THEME_PREFIX . 'intro_image'); ?>" />
</div>
</div><!-- #intro -->
<div id="main-content">
<div id="main-content-first">
<?php // Retrieve a list of latest posts or post(s) matching criteria).
$args = array('category_name' => 'Main Content First');
$customposts = get_posts($args);
foreach($customposts as $post) : setup_postdata($post); ?>
<h2 class="entry-title"><?php the_title(); ?></h2>
<div class="entry-content">
<?php the_content(); ?>
</div>
<?php endforeach; ?>
</div>
<div id="main-content-middle">
<?php // Retrieve a list of latest posts or post(s) matching criteria).
$args = array('category_name' => 'Main Content Middle');
$customposts = get_posts($args);
foreach($customposts as $post) : setup_postdata($post); ?>
<h2 class="entry-title"><?php the_title(); ?></h2>
<div class="entry-content">
<?php the_content(); ?>
</div>
<?php endforeach; ?>
</div>
<div id="main-content-last">
<?php // Retrieve a list of latest posts or post(s) matching criteria).
$args = array('category_name' => 'Main Content Last');
$customposts = get_posts($args);
foreach($customposts as $post) : setup_postdata($post); ?>
<h2 class="entry-title"><?php the_title(); ?></h2>
<div class="entry-content">
<?php the_content(); ?>
</div>
<?php endforeach; ?>
</div>
</div><!-- #main-content -->
<?php
$mypages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc');
$count = 0;
foreach($mypages as $page)
{
$content = $page->post_content;
if(!$content)
continue;
if($count >= 2)
break;
$count++;
$content = apply_filters('the_content', $content);
?>
<h2><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></h2>
<div class="entry"><?php echo $content ?></div>
<?php
}
?>
<?php get_footer(); ?>
Затем я сделал страницу About дочерней (дочернюю страницу главной страницы).
По какой-то причине ничего не отображается (см. Внизу шаблона)
Есть предложения?