Return to Snippet

Revision: 44715
at April 16, 2011 05:30 by prwhitehead


Updated Code
/**
* Makes a simple sitemap from just one shortcode
* Usage: [sitemap]
* How to: Add the function and the shortcode to your functions.php and add shortcode to any page
*/

function simple_sitemap(){
	global $wpdb; 
	$args = array('depth'        => 0,
		'show_date'    => NULL,
		'date_format'  => get_option('date_format'),
		'child_of'     => 0,
		'exclude'      => NULL,
		'include'      => NULL,
		'title_li'           => '<span class="subhead3">Pages</span>',
		'echo'         => 1,
		'authors'      => NULL,
		'sort_column'  => 'menu_order, post_title',
		'link_before'  => NULL,
		'link_after'   => NULL,
		'exclude_tree' => NULL ); 
 
	echo '<div id="sitemap"><ul>';
		wp_list_pages($args);
	echo '</ul>';
	
	$args = array('show_option_all'    => NULL,
		'orderby'            => 'name',
		'order'              => 'ASC',
		'show_last_update'   => 0,
		'style'              => 'list',
		'show_count'         => 0,
		'hide_empty'         => 1,
		'use_desc_for_title' => 1,
		'child_of'           => 0,
		'feed'               => NULL,
		'feed_type'          => NULL,
		'feed_image'         => NULL,
		'exclude'            => NULL,
		'exclude_tree'       => NULL,
		'include'            => NULL,
		'hierarchical'       => true,
		'title_li'           => '<span class="subhead3">Categories</span>',
		'number'             => NULL,
		'echo'               => 1,
		'depth'              => 0,
		'current_category'   => 0,
		'pad_counts'         => 0,
		'taxonomy'           => 'category',
		'walker'             => 'Walker_Category' );
	
        echo '<ul>';
	   echo wp_list_categories( $args );
	   echo '</ul>';	
	echo '</div>';
}
add_shortcode('sitemap', 'simple_sitemap');

Revision: 44714
at April 16, 2011 05:22 by prwhitehead


Initial Code
/**
* Makes a simple sitemap from just one shortcode
* Usage: [sitemap]
* How to: Add the function and the shortcode to your functions.php and add shortcode to any page
*/

function simple_sitemap(){
	global $wpdb; 
	$args = array('depth'        => 0,
		'show_date'    => NULL,
		'date_format'  => get_option('date_format'),
		'child_of'     => 0,
		'exclude'      => NULL,
		'include'      => NULL,
		'title_li'           => '<span class="subhead3">Pages</span>',
		'echo'         => 1,
		'authors'      => NULL,
		'sort_column'  => 'menu_order, post_title',
		'link_before'  => NULL,
		'link_after'   => NULL,
		'exclude_tree' => NULL ); 
 
	echo '<div id="sitemap"><ul>';
		wp_list_pages($args);
	echo '</ul>';
	
	$args = array('show_option_all'    => NULL,
		'orderby'            => 'name',
		'order'              => 'ASC',
		'show_last_update'   => 0,
		'style'              => 'list',
		'show_count'         => 0,
		'hide_empty'         => 1,
		'use_desc_for_title' => 1,
		'child_of'           => 0,
		'feed'               => NULL,
		'feed_type'          => NULL,
		'feed_image'         => NULL,
		'exclude'            => NULL,
		'exclude_tree'       => NULL,
		'include'            => NULL,
		'hierarchical'       => true,
		'title_li'           => '<span class="subhead3">Categories</span>',
		'number'             => NULL,
		'echo'               => 1,
		'depth'              => 0,
		'current_category'   => 0,
		'pad_counts'         => 0,
		'taxonomy'           => 'category',
		'walker'             => 'Walker_Category' );
	
        echo '<ul>';
	   echo wp_list_categories( $args );
	   echo '</ul>';	
	echo '</div>';
}
add_shortcode('sitemap', array($this, 'simple_sitemap'));

Initial URL

                                

Initial Description
Create a sitemap in wordpress, including posts, categories and pages just use the [sitemap] shortcode within the post content and wordpress / the function does the rest.

Initial Title
Wordpress Simple Sitemap

Initial Tags
php, wordpress, simple

Initial Language
PHP