Create HTML Sitemap In Wordpress Blog

How To Create Sitemap For Wordpress Blog

Wordpress-Blog-Sitemap


Sitemap make it easier for search engines to search your content.today i,m going to share you create HTML sitemap.you can do it by this php code.you can create sitemap by own self just following given instructions

1) First of all login to your wordpress hosting
2) Open file manager and find functions.php in your directory
3) copy the codes given below and paste these codes after <?php tag



function spp_html_sitemap() { $spp_sitemap = '';$published_posts = wp_count_posts('post');$spp_sitemap .= '<h4 id="sitemap-posts-h4">Here is a list of of my '.$published_posts->publish.' published posts</h4>';$args = array('exclude' => '', /* ID of categories to be excluded, separated by comma */'post_type' => 'post','post_status' => 'publish');$cats = get_categories($args);foreach ($cats as $cat) :$spp_sitemap .= '<div>';$spp_sitemap .= '<h3>Category: <a href="'.get_category_link( $cat->term_id ).'">'.$cat->cat_name.'</a></h3>';$spp_sitemap .= '<ul>';query_posts('posts_per_page=-1&cat='.$cat->cat_ID);while(have_posts()) {the_post();$category = get_the_category();/* Only display a post link once, even if it's in multiple categories */if ($category[0]->cat_ID == $cat->cat_ID) {$spp_sitemap .= '<li class="cat-list"><a href="'.get_permalink().'" rel="bookmark">'.get_the_title().'</a></li>';}}$spp_sitemap .= '</ul>';$spp_sitemap .= '</div>';endforeach;$pages_args = array('exclude' => '', /* ID of pages to be excluded, separated by comma */'post_type' => 'page','post_status' => 'publish');$spp_sitemap .= '<h3>Pages</h3>';$spp_sitemap .= '<ul>';$pages = get_pages($pages_args);foreach ( $pages as $page ) :$spp_sitemap .= '<li class="pages-list"><a href="'.get_page_link( $page->ID ).'" rel="bookmark">'.$page->post_title.'</a></li>';endforeach;$spp_sitemap .= '<ul>';return $spp_sitemap;}
add_shortcode( 'spp-sitemap','spp_html_sitemap' )






Tags:

0 Responses to “Create HTML Sitemap In Wordpress Blog”

Post a Comment

Subscribe

Donec sed odio dui. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio. Duis mollis

Designed by BloggingNeed