Skip to content

Instantly share code, notes, and snippets.

@cdils
Created February 13, 2013 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cdils/4945239 to your computer and use it in GitHub Desktop.
Save cdils/4945239 to your computer and use it in GitHub Desktop.
Partial sitemap file used in this tutorial: http://www.carriedils.com/custom-404-wordpress-html-sitemap/1574
<div class="archive-page">
<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>
<ul>
<?php
// This part prints out your custom post types
foreach( get_post_types( array('public' => true) ) as $post_type ) {
if ( in_array( $post_type, array('post','page','attachment') ) )
continue;
$pt = get_post_type_object( $post_type );
echo '<h2>'.$pt->labels->name.'</h2>';
echo '<ul>';
query_posts('post_type='.$post_type.'&posts_per_page=-1');
while( have_posts() ) {
the_post();
echo '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
}
echo '</ul>';
}
?>
</ul>
</div>
<div class="archive-page">
<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><h4>".$cat->cat_name."</h4>";
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>
</div>
@arpingajjar
Copy link

How can i exclude some pages? i am not able to exclude pages. can you please add sample.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment