Serve a humans.txt File
Answers /humans.txt with a plain-text file crediting the people and tools behind the site, generated by WordPress so you do not need to upload anything to the server.
Opens WPIDE on
Code
// File contents.
$wpide_humans_txt = "/* TEAM */\nDeveloper: Jane Doe\nContact: [email protected]\nLocation: Lisbon, Portugal\n\n/* SITE */\nStandards: HTML5, CSS3\nSoftware: WordPress";
add_action( 'init', function () {
add_rewrite_rule( '^humans\.txt$', 'index.php?wpide_humans=1', 'top' );
} );
add_filter( 'query_vars', function ( $vars ) {
$vars[] = 'wpide_humans';
return $vars;
} );
add_action( 'template_redirect', function () use ( $wpide_humans_txt ) {
if ( ! get_query_var( 'wpide_humans' ) ) {
return;
}
header( 'Content-Type: text/plain; charset=utf-8' );
header( 'X-Robots-Tag: noindex' );
echo wp_strip_all_tags( $wpide_humans_txt ) . "\n\n/* UPDATED */\nLast update: " . esc_html( mysql2date( 'Y/m/d', get_lastpostmodified( 'blog' ) ) ) . "\n";
exit;
} );
Notes
Edit $wpide_humans_txt; save Settings > Permalinks once so WordPress learns the new address. A real humans.txt file on the server takes priority.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.