-
-
Save billerickson/858ad34efdea9c75417b4217e33f8c3b to your computer and use it in GitHub Desktop.
This file contains 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 | |
/** | |
* Get markup for a HTML sitemap. | |
* | |
* Can be filtered with `genesis_sitemap_output`. | |
* | |
* If the number of published posts is 0, then Categories, Authors, | |
* Monthly and Recent Posts headings will not be shown. | |
* | |
* $heading: genesis_a11y( 'headings' ) ? 'h2' : 'h4' ); | |
* | |
* @since 2.4.0 | |
* | |
* @param string $heading Optional. Heading element. Default is `h2`. | |
* @return string $heading Sitemap content. | |
*/ | |
function genesis_get_sitemap( $heading = 'h2' ) { | |
/** | |
* Filter the sitemap before the default sitemap is built. | |
* | |
* @since 2.5.0 | |
* | |
* @param null $sitemap Null value. Change to something else to have that be returned. | |
*/ | |
$pre = apply_filters( 'genesis_pre_get_sitemap', null ); | |
if ( null !== $pre ) { | |
return $pre; | |
} | |
$sitemap = sprintf( '<%2$s>%1$s</%2$s>', __( 'Pages:', 'genesis' ), $heading ); | |
$sitemap .= sprintf( '<ul>%s</ul>', wp_list_pages( 'title_li=&echo=0' ) ); | |
$post_counts = wp_count_posts(); | |
if ( $post_counts->publish > 0 ) { | |
$sitemap .= sprintf( '<%2$s>%1$s</%2$s>', __( 'Categories:', 'genesis' ), $heading ); | |
$sitemap .= sprintf( '<ul>%s</ul>', wp_list_categories( 'sort_column=name&title_li=&echo=0' ) ); | |
$sitemap .= sprintf( '<%2$s>%1$s</%2$s>', __( 'Authors:', 'genesis' ), $heading ); | |
$sitemap .= sprintf( '<ul>%s</ul>', wp_list_authors( 'exclude_admin=0&optioncount=1&echo=0' ) ); | |
$sitemap .= sprintf( '<%2$s>%1$s</%2$s>', __( 'Monthly:', 'genesis' ), $heading ); | |
$sitemap .= sprintf( '<ul>%s</ul>', wp_get_archives( 'type=monthly&echo=0' ) ); | |
$sitemap .= sprintf( '<%2$s>%1$s</%2$s>', __( 'Recent Posts:', 'genesis' ), $heading ); | |
$sitemap .= sprintf( '<ul>%s</ul>', wp_get_archives( 'type=postbypost&limit=100&echo=0' ) ); | |
} | |
/** | |
* Filter the sitemap. | |
* | |
* @since 2.2.0 | |
* | |
* @param string $sitemap Default sitemap. | |
*/ | |
return apply_filters( 'genesis_sitemap_output', $sitemap ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment