The default Genesis Archive does a great job of creating a sitemap, but what if you want to modify it? If you’re like me and have only one author on your blog, it seems a little silly to list the authors in the site map. The following tutorial explains how to modify the default Genesis Site Map page.
This tutorial requires that you duplicate and modify a Genesis php file, but it’s is pretty simple and does not require a plugin.
IMPORTANT: This tutorial is for Genesis 2.x. Also, I recommend that you make these changes on a test site in case your changes cause problems with your site. If you don’t have a test site and these changes cause errors on your live site, you can delete page_archive.php from your child theme.
The default Genesis site map includes the following lists:
- Pages
- Categories
- Authors
- Monthly
- Recent Posts
You can modify or remove any of the default lists. In addition, you can add your own content to the page.
- Create a new Page and assign the Archive template. If you want to add introduction text above the sitemap, enter it on this page.
- In your Genesis child theme folder, create a new page called page_archive.php; for example, /wp-content/themes/agency/page_archive.php
- Find the following file and select and copy all its content:
/wp-content/themes/genesis/page_archive.php - Open the page_archive.php file in your Genesis child them and paste the contents of the original Genesis page_archive.php. If you want, you can use the following code:
<?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();
- Modify the code to add or remove content.Pages: Page 1 Page 2
Stephen says
This article was just what I needed. Excellent instructions. My site is all pages, so not only did you help me make the sitemap, but I was also able to remove the categories, etc.
Suggestion: The only other thing this article could use is a snippet for excluding pages like “thanks for contacting us” pages, etc. Now I have to go find that code somewhere else.
If I find it, I hope their instructions are as helpful as yours.
Pat Fortino says
If you want to exclude pages, see this: http://codex.wordpress.org/Function_Reference/wp_list_pages
For example, where page id equals 10.