Skip to content

Instantly share code, notes, and snippets.

@carasmo

carasmo/for-functions.php

Last active Jul 2, 2016
Embed
What would you like to do?
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
You can’t perform that action at this time.