NHSLeadership / nightingale-wp

Other
1 stars 0 forks source link

Sitemap #134

Closed Android63 closed 6 years ago

Android63 commented 6 years ago

Create sitemap page template with output as shown below:

screen shot 2018-05-01 at 17 42 44

Android63 commented 6 years ago

Hint: this is the code that needs to be inserted:

<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 class="mt">Posts</h2>

            <?php
            // Add categories you'd like to exclude in the exclude here
            $cats = get_categories('exclude=');
            foreach ($cats as $cat) {
              echo '<h3 class="mt mb-">' .$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>";
            }
            ?>