Sitemap

<?php
/*
 Template Name: Sitemap
*/
get_header(); ?>

<div class="sitemap-content">

  <h2>Pages</h2>
  <ul>
    <?php wp_list_pages( array(
      'exclude' => '', // Add page IDs to exclude if needed
      'title_li' => '',
    ) ); ?>
  </ul>

  <h2>Posts</h2>
  <ul>
    <?php
    $postsArgs = array(
      'post_type' => 'post',
      'posts_per_page' => -1,
      'post_status' => 'publish'
    );
    $postsLoop = new WP_Query($postsArgs);
    while ($postsLoop->have_posts()) {
      $postsLoop->the_post(); ?>
      <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php }
    wp_reset_postdata();
    ?>
  </ul>

  <h2>Categories</h2>
  <ul>
    <?php wp_list_categories(array(
      'title_li' => '',
      'show_count' => false,
    )); ?>
  </ul>

  <h2>Tags</h2>
  <?php
  $tags = get_tags();
  if ($tags) { ?>
    <ul>
      <?php foreach ($tags as $tag) { ?>
        <li><a href="<?php echo get_tag_link($tag->term_id); ?>"><?php echo $tag->name; ?></a></li>
      <?php } ?>
    </ul>
  <?php } ?>

</div>

<?php get_footer(); ?>