• Skip to main content

Victor Font Consulting Group, LLC

The DEX Intranet Specialists

Call Us:

+1 919-604-5828

  • Home
  • Care Plans
    • Care Articles
    • Optional Subscriptions
  • Consultations
  • Products
    • Code Snippets
    • Public GitHub Repositories
    • Gist Snippets
    • Pastebin Snippets (Free)
    • Free Plugins
  • FAQs
  • Support
    • Graphic Design
  • Contact
    • Speakers
    • Portfolio
  • Resources
    • Free WordPress Video Training
    • Tutorials
    • Articles
    • Cybersecurity
    • EU Referral Network
You are here: Home / Accessibility / genesis_sitemap_output Filter

genesis_sitemap_output Filter

By Victor M. Font Jr.
November 11, 20153 Comments

Filter Genesis Sitemap with genesis_sitemap_output, public domain image from pixabay.com

One feature of the Genesis Framework is the ability to easily create an archive page. Create a new page, assign the Archive template to it, and you're done. When you add it to a menu, the archive page displays links to all pages, categories, authors, monthly archives, and your last 100 posts.

Archive pages are sometimes referred to as sitemaps, but please don't confuse this type of sitemap with the XML sitemap that you register with the search engines to help index your site. While both of these sitemaps help your SEO and indexing, they are distinct tools and output their data very differently.

As with all things, times they are a-changin', and the release of Genesis 2.2 changed a lot. For example, examine the old and new page_archive.php source codes displayed below. In the "Out with the Old" section, page_archive.php had all of the code within the template to generate the sitemap. You'll see the bulk of this code in the genesis_page_archive_content() function (highlighted).

In the "In with the New" section, you don't see the archive code at all. What you see is a new function called genesis_sitemap. It is this function that now drives the content of archive pages. This function is found in genesis/lib/functions/general.php. For your convenience, the source code may be viewed below. But notice something magical at line 40—that's right, it's a filter! While it's beyond the scope of this article to fully explain filters, I will say that they make it easy to change how a function works.

Out with the Old

In Genesis versions earlier than the 2.2 release, the page_archive.php file contained:

You'll find tutorials all over the Internet about how to change this version of the page to customize your sitemap's output. For example, suppose you don't want the author archives to display, you would comment out lines 39 through 44 as I've done in the above example.

In with the New

Since the release of Genesis Version 2.2, the new page_archive.php contains:

Much simpler, isn't it? While the genesis_page_archive_content() function hasn't shown up on the deprecated list yet, its output content has essentially been replaced by genesis_sitemap() in Version 2.2. So the question becomes, "How do I remove the author section now?" Genesis_sitemap is a core function that should never be changed, but remember the filter? Let's jump ahead to the Filter Genesis Sitemap with genesis_sitemap_output section to learn how.

genesis_sitemap()

Filter Genesis Sitemap with genesis_sitemap_output

To remove the author content from the new page_archive.php, we need to add a new filter to the child theme's functions.php. I've chosen not to pass any parameters to my new function. In the genesis_sitemap function, the heading parameter is passed. In this new function, I've decided to determine the proper headings for the archive page by including the same code that is used on line 36 in the code above. I've also copied the content from genesis_sitemap into my new function. Here I can comment out the author archives (lines 12 through 15).

The are other ways you can use the genesis_sitemap_output filter as well. In the first example, you can modify the text that displays as headers. In the second example, you can replace the sitemap altogether with a WordPress function.

Example 1

Example 2

See? I told you it was magic.

  • 5shares
  • Facebook0
  • Twitter2
  • Pinterest0
  • LinkedIn2
  • Print
  • SMS1

About Victor M. Font Jr.

Victor M. Font Jr. is an award winning author, entrepreneur, and Senior IT Executive. A Founding Board Member of the North Carolina Executive Roundtable, he has served on the Board of Advisors, of the North Carolina Technology Association, the International Institute of Business Analysis, Association of Information Technology Professionals, Toastmasters International, and the North Carolina Commission for Mental Health, Developmental Disabilities, and Substance Abuse Services. He is author of several books including The Ultimate Guide to the SDLC and Winning With WordPress Basics, and Cybersecurity.

Reader Interactions

VictorFont.com runs on the Genesis Framework

Genesis FrameworkThe Genesis Framework empowers you to quickly and easily build incredible websites with WordPress. Genesis provides the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go.

Check out the incredible features and the selection of designs. It's that simple—start using Genesis now!

Click here to download The Genesis Guide for Absolute Beginners (PDF - 1.4 MB)

Leave a Reply Cancel reply

Your email address and website will not be published. Required fields are marked *
Posting a comment means that you agree with and accept our Comment & Product Review Policy

Comments

  1. Stephanie Powers

    January 15, 2017 at 7:57 pm

    Thank you so much for sharing this! I had used the old way to filter out Authors, etc on my 404 page and searched for quite a while before finally finding the answer you provided on filtering the new sitemap content.

    Reply
  2. J. Marshall

    August 29, 2016 at 1:52 pm

    Great article! Very clear with full information and perfect examples. Very, very helpful.

    Reply
  3. Brian

    August 18, 2016 at 12:41 pm

    Thanks Victor for this simple, accurate and up-to-date [unlike most results from a Search Engine’s irrelevant & inaccurate spew] explanation.

    Took a while to find but, that said, exactly what I was looking for & works just great for me.

    Thank you

    Reply

Call: +1 919-604-5828

Send us an E-mail

Accessibility Statement | Affiliate Marketing Disclosure | Capability Statement

Cookie Policy | Comment & Product Review Policy | Privacy Policy | Site Map | Terms & Conditions

Copyright © 2003–2023 Victor M. Font Jr.

Return to top of page