Sitemap

/*
Put the following code in your themes functions.php file
*/
function get_html_sitemap( $atts ){

$return = ”;
$args = array(‘public’=>1);

// If you would like to ignore some post types just add them to the array below
$ignoreposttypes = array(‘attachment’);

$post_types = get_post_types( $args, ‘objects’ );

foreach ( $post_types as $post_type ) {
if( !in_array($post_type->name,$ignoreposttypes)){
$return .= ‘

‘ . $post_type->labels->name.’

‘;
$args = array(
‘posts_per_page’ => -1,
‘post_type’ => $post_type->name,
‘post_status’ => ‘publish’
);
$posts_array = get_posts( $args );
$return .= ‘

    • ‘;

 

    • foreach($posts_array as $pst){

 

‘;
}
$return .= ‘

‘;
}
}

return $return;
}
add_shortcode( ‘htmlSitemap’, ‘get_html_sitemap’ );

Facebook Comments