Adding humans.txt to WordPress

humans.txt is a simple but meaningful way for web developers (and other contributors) to take credit for their work and leave a trace of their presence on the web. Given enough time, everything a web developer touches tends to disappear. The ability to preserve any footprint is limited. All our code, our ingenuity, our shameless hacks eventually get refactored or deleted.

The humans.txt file offers one small corner of the internet where, if you’re lucky, a simple acknowledgement might remain. This is especially valuable on websites that are updated and maintained by different teams over time.

I’ve been listed in the humans.txt file of several sites I no longer work on or have access to. A few still survive, but most are long gone:

Enable humans.txt

<?php 
/** 
 * Register the rewrite rule for /humans.txt request.
 */
function add_humans_txt_rewrite() { 
	add_rewrite_rule( '^humans\.txt$', 'index.php?humans_txt=true', 'top' );
}
add_action( 'init', 'add_humans_txt_rewrite', 10 );

/**
 * Filter the list of public query vars in order to allow the WP::parse_request
 * to register the query variable.
 * 
 * @param array $public_query_vars The array of whitelisted query variables. 
 * 
 * @return array
 */ 
function add_humans_txt_query_var( $public_query_vars ) {
	$public_query_vars[] = 'humans_txt';
	return $public_query_vars;
}
add_filter( 'query_vars', 'add_humans_txt_query_var', 10, 1 );

/**
 * Hook the parse_request action and serve the humans.txt when custom query variable is set to 'true'.
 *
 * @param WP $wp Current WordPress environment instance
 */
function get_humans_txt_request( $wp ) {
	if ( isset( $wp->query_vars['humans_txt'] ) && 'true' === $wp->query_vars['humans_txt'] ) {
		header( 'Content-Type: text/plain' );
		echo file_get_contents( get_stylesheet_directory() . '/humans.txt' );
		exit;
	}
} 
add_action( 'parse_request', 'get_humans_txt_request', 10, 1 );

/**
 * Add a LINK tag in the HEAD of your main page
 */
function add_humans_txt_link() {
	if (is_front_page()) {
		echo '<link rel="author" href="humans.txt" />';
	}
};

add_action('wp_head', 'add_humans_txt_link');

Write humans.txt

This is the plain-text template I suggest using. Add the newest team member to the top of the list. When someone leaves, move them to the Alumni section.

Over the years, I’ve had a few people mention they discovered job listings through this file, so it can serve more than just a credit log.

The file includes information about the people who have contributed to the development of the website, developers, designers, product managers, and others who’ve played a role in shaping the site.

# TEAM

These shiny humans help direct the ones and zeros that run example.com:

    Sigourney Weaver  instagram.com/official_sigourneyweaver
    Michael Donohoe   https://bsky.app/profile/donohoe.dev

# ALUMNI

These humans have helped us to be what we are today:

    Ed Norton         twitter.com/edwardnorton
    Peter O'Toole     peter (at) gmail dot com

# CONTACT

Help, questions, and general support:

    hello@example.com

# WORK WITH US \( °□° )/

Come join us, we're hiring (sometimes): 

    https://example.com/hiring/

I would suggest using this to create a hoomans.txt to list people’s dogs, but I have too much time on my hands.