Created
May 25, 2018 00:17
-
-
Save patric-boehner/b50469868acd4f1027d33bd4d0696551 to your computer and use it in GitHub Desktop.
Filter the genesis sitemap function to remove authors, tags and add support for custom post types
This file contains hidden or 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 | |
| // Don't include opening php | |
| // Sitemap Output | |
| add_filter( 'genesis_sitemap_output', 'pb_customize_sitemap_output' ); | |
| function pb_customize_sitemap_output() { | |
| $heading = ( genesis_a11y( 'headings' ) ? 'h2' : 'h4' ); | |
| // Pages | |
| $sitemap = sprintf( '<%2$s>%1$s</%2$s>', __( 'Pages:', 'blank-child-theme' ), $heading ); | |
| $sitemap .= sprintf( '<ul>%s</ul>', wp_list_pages( 'title_li=&echo=0' ) ); | |
| // Post Type | |
| // $sitemap .= sprintf( '<%2$s>%1$s</%2$s>', __( 'Post Type:', 'blank-child-theme' ) , $heading ); | |
| // $sitemap .= sprintf( '<ul>%s</ul>', wp_get_archives( 'type=postbypost&limit=10&echo=0&post_type=pb_cpt_services' ) ); | |
| // Authors | |
| // $sitemap .= sprintf( '<%2$s>%1$s</%2$s>', __( 'Authors:', 'blank-child-theme' ), $heading ); | |
| // $sitemap .= sprintf( '<ul>%s</ul>', wp_list_authors( 'exclude_admin=0&optioncount=1&echo=0' ) ); | |
| // Date Archives | |
| // $sitemap .= sprintf( '<%2$s>%1$s</%2$s>', __( 'Monthly:', 'blank-child-theme' ), $heading ); | |
| // $sitemap .= sprintf( '<ul>%s</ul>', wp_get_archives( 'type=monthly&echo=0' ) ); | |
| // Categories | |
| $sitemap .= sprintf( '<%2$s>%1$s</%2$s>', __( 'Categories:', 'blank-child-theme' ), $heading ); | |
| $sitemap .= sprintf( '<ul>%s</ul>', wp_list_categories( 'sort_column=name&title_li=&echo=0' ) ); | |
| // Blog Posts | |
| $sitemap .= sprintf( '<%2$s>%1$s</%2$s>', __( 'Blog Posts:', 'blank-child-theme' ) , $heading ); | |
| $sitemap .= sprintf( '<ul>%s</ul>', wp_get_archives( 'type=postbypost&limit=100&echo=0' ) ); | |
| return $sitemap; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment