Skip to content

Instantly share code, notes, and snippets.

@carasmo
Last active July 2, 2016 19:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carasmo/70180a3a54063a3398da to your computer and use it in GitHub Desktop.
Save carasmo/70180a3a54063a3398da to your computer and use it in GitHub Desktop.
Custom genesis_sitemap_output using the previously created custom get_posts() function to exclude posts or show only a specific category.
<?php
// don't include
/** ====================================================================================
* SITE MAP : archive page filter for genesis_sitemap_output();
* using christina_get_posts_for_sitemap();
==================================================================================== **/
function christina_sitemap($sitemap_post_list) {
$heading = ( genesis_a11y( 'headings' ) ? 'h2' : 'h4' );
// PAGES: heading for pages begins the list notice the variable has no dot before the equal sign
$sitemap = sprintf( '<%2$s>%1$s</%2$s>', __( 'Pages:', 'genesis' ), $heading );
// PAGES: list pages but exclude the site map page itself
$sitemap .= sprintf( '<ul>%s</ul>', wp_list_pages( 'exclude=1100&title_li=&echo=0' ) );
// POSTS: heading for posts
$sitemap .= sprintf( '<%2$s>%1$s</%2$s>', __( 'Recent Posts:', 'genesis' ) , $heading );
// POSTS: using the christina_get_posts_for_sitemap() to list recent posts and use get_post arguments
$sitemap .= christina_get_posts_for_sitemap();
//CATEGORIES: heading
$sitemap .= sprintf( '<%2$s>%1$s</%2$s>', __( 'Categories:', 'genesis' ) , $heading );
//CATEGORIES: list exclude uncategorized
$sitemap .= sprintf( '<ul>%s</ul>', wp_list_categories( 'exclude=1&sort_column=name&title_li=&echo=0' ) );
//MONTHLY: heading
$sitemap .= sprintf( '<%2$s>%1$s</%2$s>', __( 'Monthly:', 'genesis' ) , $heading );
//MONTHLY: posts
$sitemap .= sprintf( '<ul>%s</ul>', wp_get_archives( 'type=monthly&echo=0' ) );
echo $sitemap;
}
add_filter( 'genesis_sitemap_output', 'christina_sitemap' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment