Sitemap is useful thing for any kinds of websites. with sitemap you can show all of your web content in one place and submit easily on search engine. for creating sitemap of your wordpress you can use many plugins but plugin use is not good for wordpress. if you want you can create a nice dynamic sitemap for your wordpress without any kinds of plugins. so for this please follow this instruction very carefully.
1. At first copy below code:
3. Now create a new page named 'sitemap' in your wordpress blog and at content area paste this small code:
4. Now publish yor page.
for clear understanding see this picture:
You done this!!! now visit your created 'sitemap' page. there you will look nice sitemap created.
1. At first copy below code:
/*2. now paste it in your wordpress blogs current themes 'functions.php' file and save it.
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 .= '<h2>' . $post_type->labels->name.'</h2>';
$args = array(
'posts_per_page' => -1,
'post_type' => $post_type->name,
'post_status' => 'publish'
);
$posts_array = get_posts( $args );
$return .= '<ul>';
foreach($posts_array as $pst){
$return .= '<li><a href="'.get_permalink($pst->ID).'">'.$pst->post_title.'</a></li>';
}
$return .= '</ul>';
}
}
return $return;
}
add_shortcode( 'htmlSitemap', 'get_html_sitemap' );
3. Now create a new page named 'sitemap' in your wordpress blog and at content area paste this small code:
[htmlSitemap]any problems copy code here
4. Now publish yor page.
for clear understanding see this picture:
You done this!!! now visit your created 'sitemap' page. there you will look nice sitemap created.
0 comments:
Post a Comment
Comments here