2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

著者ページを無効にする

Posted at

複数の著者が書くブログのようなウェブサイトでなければ,そもそも著者ページは必要ありませんし,セキュリティ上よいことではありませんが,ユーザーIDがよくあるものになっている場合,第三者によってそのことを確認するためにアクセスされてしまうので,無効にします.

stinc/src/basic/blocker.php
function disable_author_page() {
	add_filter( 'author_rewrite_rules', '__return_empty_array' );
	add_filter( 'author_link', '__return_empty_string' );

	add_filter( 'parse_query', function ( $query ) {
		if ( ! is_admin() && is_author() ) {
			$query->set_404();
			status_header( 404 );
			nocache_headers();
		}
	} );

	// Remove authors from feeds
	add_filter( 'the_author', function ( $author ) {
		return is_feed() ? get_bloginfo( 'name' ) : $author;
	} );
	add_filter( 'the_author_url', function ( $author_meta ) {
		return is_feed() ? home_url() : $author_meta;
	} );
}
2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?