Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php /* Template Name: Sitemap */
- get_header();
- ?>
- <div id="primary" class="content-area col-lg-8 offset-lg-2 pt-5">
- <main id="main" class="site-main">
- <h1>HTML Sitemap</h1>
- <h2 id="pages">Pages</h2>
- <ul>
- <?php
- // Add pages you'd like to exclude in the exclude here
- wp_list_pages(
- array(
- 'exclude' => '',
- 'title_li' => '',
- )
- );
- ?>
- </ul>
- <h2 id="posts">Posts</h2>
- <ul>
- <?php
- // Add categories you'd like to exclude in the exclude here
- $cats = get_categories('exclude=');
- foreach ($cats as $cat) {
- echo "<li><h3>".$cat->cat_name."</h3>";
- echo "<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) {
- echo '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
- }
- }
- echo "</ul>";
- echo "</li>";
- }
- ?>
- </ul>
- <h2>Categories</h2>
- <ul><?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0&feed=RSS'); ?></ul>
- </main><!-- #main -->
- </div><!-- #primary -->
- <?php
- get_footer();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement