Skip to content

Instantly share code, notes, and snippets.

@kachi
Created March 25, 2012 17:34
<?php
function subpage_peek() {
global $post;
$args = array(
'post_parent' => $post->ID,
'post_type' => 'page'
);
$subpages = new WP_query($args);
if ($subpages->have_posts()) :
$output = '<ul>';
while ($subpages->have_posts()) : $subpages->the_post();
$output .= '<li><strong><a href="'.get_permalink().'">'.get_the_title().'</a></strong>
<p>'.get_the_excerpt().'<br />
<a href="'.get_permalink().'">続きを読む →</a></p></li>';
endwhile;
$output .= '</ul>';
else :
$output = '<p>ありません</p>';
endif;
wp_reset_postdata();
return $output;
}
add_shortcode('subpage_peek', 'subpage_peek');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment