Skip to content

Instantly share code, notes, and snippets.

@horaotoko
Created October 9, 2012 08:33
Show Gist options
  • Save horaotoko/3857368 to your computer and use it in GitHub Desktop.
Save horaotoko/3857368 to your computer and use it in GitHub Desktop.
子ページ取得
<?php
$page_id = mysql_real_escape_string( $post -> ID );
$array = $wpdb -> get_results( "SELECT ID, post_title, post_content FROM $wpdb->posts WHERE post_parent = '$page_id' AND post_status = 'publish'" );
foreach ( $array as $value ) {
echo '<h2><a href="' . get_permalink( $value -> ID ) . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'twentyten' ), esc_attr( strip_tags( $value -> post_title ) ) ) . '" rel="bookmark">' . esc_attr( strip_tags( $value -> post_title ) ) . '</a></h2>' . "\n";
echo apply_filters( 'the_content', $value -> post_content );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment