carasmo
2/24/2016 - 7:06 PM

Custom genesis_sitemap_output using the previously created custom get_posts() function to exclude posts or show only a specific category.

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' );