Skip to content

Instantly share code, notes, and snippets.

@szbl
Created May 18, 2009 17:07
Show Gist options
  • Save szbl/113615 to your computer and use it in GitHub Desktop.
Save szbl/113615 to your computer and use it in GitHub Desktop.
<?php
/*
Plugin Name: List Children
Plugin Author: Andy Stratton
Plugin URI: http://theandystratton.com
Author URI: http://theandystratton@gmail.com
Version: 1.0
Description: Use an HTML comment (<code>&lt;!--list_children()--&gt;</code>) in post content to call wp_list_pages for sub-pages of the current page.
*/
function lc_list_pages( $sort_column = 'menu_order', $sort_order = 'ASC' ) {
return wp_list_pages('echo=0&title_li=&child_of=' . get_the_ID() . "&sort_column=$sort_column&sort_order=$sort_order");
}
function lc_list_pages_content( $content ) {
$comment = '<!--list_children()-->';
$content = str_replace($comment, lc_list_pages(), $content);
return $content;
}
add_filter('the_content', 'lc_list_pages_content');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment