Last active
May 4, 2020 11:44
-
-
Save vfontjr/987e017a59e69992e070ad57e5678f5c to your computer and use it in GitHub Desktop.
Source code for https://victorfont.com/genesis_sitemap_output-filter/
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 | |
add_filter( 'genesis_sitemap_output', 'vmf_replace_sitemap' ); | |
function vmf_replace_sitemap() { | |
$sitemap = '<p>Thank you for visiting our site. Here is a list of our main pages.</p><ul>'; | |
$sitemap .= wp_list_pages( 'title_li=&depth=1&echo=0' ); | |
$sitemap .= sprintf( '</ul><a href="%s">Back Home</a>', home_url() ); | |
return $sitemap; | |
} |
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 | |
add_filter( 'genesis_sitemap_output', 'vmf_replace_text' ); | |
function vmf_replace_text( $sitemap ) { | |
$sitemap = str_replace( 'Pages', 'Important Information', $sitemap ); | |
$sitemap = str_replace( 'Recent Posts', 'Newest Articles', $sitemap ); | |
return $sitemap; | |
} |
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 | |
/** | |
* Add a sitemap | |
* Used in page_archive.php and 404.php, can be filtered | |
* | |
* $heading: genesis_a11y( 'headings' ) ? 'h2' : 'h4' ); | |
* | |
* @since 2.2.0 | |
* | |
* @param string $heading | |
* | |
* @return string $heading Sitemap content | |
* | |
*/ | |
function genesis_sitemap( $heading = 'h2' ) { | |
$sitemap = sprintf( '<%2$s>%1$s</%2$s>', __( 'Pages:', 'genesis' ), $heading ); | |
$sitemap .= sprintf( '<ul>%s</ul>', wp_list_pages( 'title_li=&echo=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. | |
* } | |
*/ | |
$sitemap = apply_filters( 'genesis_sitemap_output', $sitemap ); | |
echo $sitemap; | |
} |
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 | |
/** | |
* Genesis Framework. | |
* | |
* WARNING: This file is part of the core Genesis Framework. DO NOT edit this file under any circumstances. | |
* Please do all modifications in the form of a child theme. | |
* | |
* @package Genesis\Templates | |
* @author StudioPress | |
* @license GPL-2.0+ | |
* @link http://my.studiopress.com/themes/genesis/ | |
*/ | |
//* Template Name: Archive | |
//* Remove standard post content output | |
remove_action( 'genesis_post_content', 'genesis_do_post_content' ); | |
remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); | |
add_action( 'genesis_entry_content', 'genesis_page_archive_content' ); | |
add_action( 'genesis_post_content', 'genesis_page_archive_content' ); | |
/** | |
* This function outputs sitemap-esque columns displaying all pages, | |
* categories, authors, monthly archives, and recent posts. | |
* | |
* @since 1.6 | |
* | |
* @uses genesis_a11y() to check for headings choice. | |
* @uses genesis_sitemap() to generate the sitemap. | |
* | |
*/ | |
function genesis_page_archive_content() { | |
$heading = ( genesis_a11y( 'headings' ) ? 'h2' : 'h4' ); | |
genesis_sitemap( $heading ); | |
} | |
genesis(); |
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 | |
/** | |
* Genesis Framework. | |
* | |
* WARNING: This file is part of the core Genesis Framework. DO NOT edit this file under any circumstances. | |
* Please do all modifications in the form of a child theme. | |
* | |
* @package Genesis\Templates | |
* @author StudioPress | |
* @license GPL-2.0+ | |
* @link http://my.studiopress.com/themes/genesis/ | |
*/ | |
//* Template Name: Archive | |
//* Remove standard post content output | |
remove_action( 'genesis_post_content', 'genesis_do_post_content' ); | |
remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); | |
add_action( 'genesis_entry_content', 'genesis_page_archive_content' ); | |
add_action( 'genesis_post_content', 'genesis_page_archive_content' ); | |
/** | |
* This function outputs sitemap-esque columns displaying all pages, | |
* categories, authors, monthly archives, and recent posts. | |
* | |
* @since 1.6 | |
*/ | |
function genesis_page_archive_content() { ?> | |
<h4><?php _e( 'Pages:', 'genesis' ); ?></h4> | |
<ul> | |
<?php wp_list_pages( 'title_li=' ); ?> | |
</ul> | |
<h4><?php _e( 'Categories:', 'genesis' ); ?></h4> | |
<ul> | |
<?php wp_list_categories( 'sort_column=name&title_li=' ); ?> | |
</ul> | |
<!-- | |
<h4><?php _e( 'Authors:', 'genesis' ); ?></h4> | |
<ul> | |
<?php wp_list_authors( 'exclude_admin=0&optioncount=1' ); ?> | |
</ul> | |
--> | |
<h4><?php _e( 'Monthly:', 'genesis' ); ?></h4> | |
<ul> | |
<?php wp_get_archives( 'type=monthly' ); ?> | |
</ul> | |
<h4><?php _e( 'Recent Posts:', 'genesis' ); ?></h4> | |
<ul> | |
<?php wp_get_archives( 'type=postbypost&limit=100' ); ?> | |
</ul> | |
<?php | |
} | |
genesis(); |
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 | |
/* add this to your child theme's functions.php */ | |
add_filter( 'genesis_sitemap_output', 'vmf_sitemap' ); | |
function vmf_sitemap() { | |
$heading = ( genesis_a11y( 'headings' ) ? 'h2' : 'h4' ); | |
$sitemap = sprintf( '<%2$s>%1$s<!--%2$s-->', __( 'Pages:', 'genesis' ), $heading ); | |
$sitemap .= sprintf( '<ul>%s</ul>', wp_list_pages( 'title_li=&echo=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' ) ); | |
return $sitemap; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment