Advertisement
isaacadams

Sitemap.php

Apr 20th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. <?php /* Template Name: Sitemap */
  2.  
  3. get_header();
  4. ?>
  5.  
  6. <div id="primary" class="content-area col-lg-8 offset-lg-2 pt-5">
  7. <main id="main" class="site-main">
  8. <h1>HTML Sitemap</h1>
  9. <h2 id="pages">Pages</h2>
  10. <ul>
  11. <?php
  12. // Add pages you'd like to exclude in the exclude here
  13. wp_list_pages(
  14. array(
  15. 'exclude' => '',
  16. 'title_li' => '',
  17. )
  18. );
  19. ?>
  20. </ul>
  21.  
  22. <h2 id="posts">Posts</h2>
  23. <ul>
  24. <?php
  25. // Add categories you'd like to exclude in the exclude here
  26. $cats = get_categories('exclude=');
  27. foreach ($cats as $cat) {
  28. echo "<li><h3>".$cat->cat_name."</h3>";
  29. echo "<ul>";
  30. query_posts('posts_per_page=-1&cat='.$cat->cat_ID);
  31. while(have_posts()) {
  32. the_post();
  33. $category = get_the_category();
  34. // Only display a post link once, even if it's in multiple categories
  35. if ($category[0]->cat_ID == $cat->cat_ID) {
  36. echo '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
  37. }
  38. }
  39. echo "</ul>";
  40. echo "</li>";
  41. }
  42. ?>
  43. </ul>
  44.  
  45. <h2>Categories</h2>
  46. <ul><?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0&feed=RSS'); ?></ul>
  47.  
  48. </main><!-- #main -->
  49. </div><!-- #primary -->
  50.  
  51. <?php
  52. get_footer();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement