Created
January 8, 2025 23:29
-
-
Save benpearson/fc76bf76349e49c23a48627dd1a63dde to your computer and use it in GitHub Desktop.
Wordpress: Sitemap page template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Template Name: Sitemap | |
*/ | |
?> | |
<?php get_header(); ?> | |
<div class="site-map"> | |
<?php // Pages | |
?> | |
<div class="site-map__col"> | |
<h4>Pages</h4> | |
<ul> | |
<?php wp_list_pages(array( | |
'title_li' => '', | |
// 'exclude' => '32,34,27' | |
)); ?> | |
</ul> | |
</div> | |
<?php // News | |
$posts_query = new WP_Query(array( | |
'posts_per_page' => -1 | |
)); | |
if ($posts_query->have_posts()) : ?> | |
<div class="site-map__col"> | |
<h4>News</h4> | |
<h5>Articles</h5> | |
<ul> | |
<?php while ($posts_query->have_posts()) : | |
$posts_query->the_post(); ?> | |
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> | |
<?php endwhile; | |
wp_reset_postdata(); ?> | |
</ul> | |
<h5>Categories</h5> | |
<ul> | |
<?php wp_list_categories(array( | |
'title_li' => '' | |
)); ?> | |
</ul> | |
</div> | |
<?php endif; ?> | |
<?php /* | |
<?php // Resources | |
$resources_query = new WP_Query(array( | |
'post_type' => 'resource', | |
'posts_per_page' => -1 | |
)); | |
if ($resources_query->have_posts()) : ?> | |
<div class="site-map__col"> | |
<h4>Resources</h4> | |
<ul> | |
<?php while ($resources_query->have_posts()) : | |
$resources_query->the_post(); ?> | |
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> | |
<?php endwhile; | |
wp_reset_postdata(); ?> | |
</ul> | |
</div> | |
<?php endif; ?> | |
*/ ?> | |
</div> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment