SiteMap
From Wiki.cyring.fr
Contents |
Function SiteMap for WordPress
The PHP function
function fSiteMap( $atts ) {
$fstring = '<div id="SiteMap"><ul>';
foreach(get_categories('orderby=name') as $category) {
$fstring = $fstring . '<li><input type="checkbox" checked="checked" id=' . $category->cat_ID . ' /><label for=' . $category->name . '>' . $category->name . '</label><ul>';
foreach(get_posts('numberposts=-1&category=' . $category->cat_ID) as $item)
$fstring = $fstring . '<li>' . strftime("%x ", strtotime($item->post_date)) . '<a href=' . get_permalink($item->ID) . '>' . get_the_title($item->ID) . '</a> (' . $item->comment_count . ')</li>';
$fstring = $fstring . '</ul></li>';
}
$fstring = $fstring . '</ul></div>';
return ($fstring);
}
Instancing into the WordPress theme loop
function twentyten_setup() {
// ...
add_shortcode( 'sitemap', 'fSiteMap' );
}
Inserting into a page
- Just add [sitemap] anywhere in your page.