(2026年10月29日 追記:記事どおりに再現できるよう、必要なコードと手順を追加しました)
キュレーションメディアの記事を読んだ読者が最初に気にするのは、「この情報は誰が書いて、誰が確認したのか」です。特にセキュリティやお金、健康など、判断を誤ると困る分野では、書き手の経歴や監修の有無が記事を信頼できるかどうかの手がかりになります。
「記事に著者と監修者のプロフィールを出したい。WordPress の標準機能だけで足りる? 監修者は記事ごとに選べるようにしたい」
結論から言うと、著者の肩書き・専門分野はユーザーメタ(=ユーザーごとの追加情報)、監修者は投稿メタ(=記事ごとの追加情報)として小さなプラグインに登録し、表示は「著者ボックス」ブロックをテンプレートに置く形が保守しやすくおすすめです。WordPress 6.8 の標準の仕組み(register_meta、エディターのサイドバー拡張、動的ブロック)で実装できます。
前回の第5回では、まとめリストと比較表をパターンとブロックスタイルで作りました。第6回の今回は、著者・監修者のプロフィールを登録・表示する仕組みを作ります。
E-E-A-T と著者情報:Google の説明を正しく押さえる
著者情報の話になると、よく「E-E-A-T」という言葉が出てきます。まず、Google 自身がどう説明しているかを確認しておきます(以下は2025年8月時点の Google 検索セントラルの記述に基づきます)。
- E-E-A-T は、エクスペリエンス(Experience)、専門性(Expertise)、権威性(Authoritativeness)、信頼性(Trustworthiness)の頭文字で、中でも信頼性が最も重要とされています。
- Google は、E-E-A-T 自体はランキングに直接影響する要因ではないと明記しています。
- そのうえで、コンテンツを「誰が、どのように、なぜ」作ったかという観点で見直すことを勧めており、「誰が」については、著者が誰かを明確にしているか、しかるべき場所にバイライン(=著者名の表示)があるか、それが著者の経歴や専門分野の情報につながっているか、といった問いを挙げています。
📰 出典:Google 検索セントラル「有用で信頼性の高い、ユーザーを第一に考えたコンテンツの作成」
つまり、著者・監修者を表示すれば検索順位が上がる、というものではありません。この連載では、著者情報の表示を「読者が記事の信頼性を自分で判断するための情報」として実装します。検索エンジンのためではなく、読者のために書き手を明らかにする、という位置づけです。
今回のゴールと、データの置き場所
完成すると、次のように動きます。
- 「ユーザー > プロフィール」に、肩書き・専門分野・プロフィールURLの入力欄が増える
- 投稿の編集画面の右側(「投稿」タブ)に「監修」パネルが増え、監修者と監修日を選べる
- 記事の本文の下に、著者のプロフィールが表示される。監修者を設定した記事でのみ、監修者のプロフィールと監修日も表示される
- 著者名から著者アーカイブ(その人の記事一覧)に移動でき、そこにもプロフィールが表示される
データの置き場所は次のように分けました。
| 情報 | 保存先 | 理由 |
|---|---|---|
| 名前・紹介文 | WordPress 標準のユーザー情報(表示名、プロフィール情報) | 既存の項目をそのまま使う |
| 肩書き・専門分野・プロフィールURL | ユーザーメタ(curation_job_title など) | 人に付く情報で、どの記事でも同じ |
| 監修者・監修日 | 投稿メタ(_curation_supervisor_id、_curation_supervised_on) | 記事ごとに違う情報 |
監修者も WordPress のユーザーとして登録し、記事ではユーザーを選ぶ方式にしました。名前を記事ごとに手入力すると、表記ゆれや経歴の更新漏れが起きるためです。
今回追加・変更したファイル
| ファイル | 内容 |
|---|---|
プラグイン includes/profile-fields.php | ユーザーメタの登録とプロフィール画面の入力欄(新規) |
プラグイン includes/meta.php | 監修者・監修日の投稿メタと、監修パネルの読み込み(新規) |
プラグイン editor/supervisor-panel.js | エディターの「監修」パネル(新規) |
プラグイン blocks/author-box/ | 著者ボックスの動的ブロック(新規) |
プラグイン webpack.config.js | ブロック以外の JS もビルドする設定(新規) |
プラグイン curation-tools.php | 読み込みとブロック登録の追加、バージョン 0.6.0 |
テーマ parts/author-box.html | 著者・監修者のテンプレートパーツ(新規) |
テーマ templates/single*.html | 3つの記事テンプレートにパーツを追加 |
テーマ templates/author.html | 著者アーカイブ(新規) |
テーマ theme.json・style.css | テンプレートパーツの登録、バージョン 0.6.0 |
この回で新しく使うフォルダを作ります(プロジェクトのフォルダで実行)。
mkdir -p wp-content/plugins/curation-tools/blocks/author-box \
wp-content/plugins/curation-tools/editor
著者のプロフィール項目をユーザーメタで追加する
まず、肩書き・専門分野・プロフィールURLをユーザーメタとして登録します。
wp-content/plugins/curation-tools/includes/profile-fields.php(説明用の抜粋。全文はこの節の最後)
function curation_tools_register_profile_meta() {
foreach ( curation_tools_profile_fields() as $key => $field ) {
register_meta(
'user',
$key,
array(
'type' => 'string',
'description' => $field['label'],
'single' => true,
'default' => '',
'show_in_rest' => true,
'sanitize_callback' => 'url' === $field['type'] ? 'esc_url_raw' : 'sanitize_text_field',
// 第3引数はメタを更新する対象のユーザーID。そのユーザーを編集できる人だけが更新できる。
'auth_callback' => static function ( $allowed, $meta_key, $user_id ) {
return current_user_can( 'edit_user', $user_id );
},
)
);
}
}
add_action( 'init', 'curation_tools_register_profile_meta' );
register_meta() で型・サニタイズ(=入力値を安全な形に整えること)・編集できる人を決めておくと、管理画面・REST API・WP-CLI のどこから保存しても同じルールが適用されます。URL の項目は esc_url_raw を通すため、javascript: のような値は空になります。
📰 出典:WordPress Developer Resources「register_meta()」
show_in_rest を true にした項目は、REST API で誰でも読めるようになります。WordPress の /wp-json/wp/v2/users/<ID> は、記事を公開しているユーザーの情報を認証なしで返すためです。そのため、ここには「公開ページに表示してよい項目」だけを登録し、電話番号や社内の連絡先などは入れないようにします。
プロフィール画面への入力欄の追加と保存は、show_user_profile などのフックで行います。
includes/profile-fields.php(保存処理の抜粋)
function curation_tools_save_profile_fields( $user_id ) {
check_admin_referer( 'update-user_' . $user_id );
if ( ! current_user_can( 'edit_user', $user_id ) ) {
return;
}
foreach ( array_keys( curation_tools_profile_fields() ) as $key ) {
if ( isset( $_POST[ $key ] ) ) {
// サニタイズは register_meta の sanitize_callback が update_user_meta 時に行う。
update_user_meta( $user_id, $key, wp_unslash( $_POST[ $key ] ) );
}
}
}
add_action( 'personal_options_update', 'curation_tools_save_profile_fields' );
add_action( 'edit_user_profile_update', 'curation_tools_save_profile_fields' );
WordPress 本体もプロフィール画面の nonce(=フォームが正規の画面から送られたことを確認する合言葉)を確認していますが、このフックは他の処理から呼ばれる可能性もあるため、nonce と権限をここでも確認しています。入力欄の表示部分では、値をすべて esc_attr() でエスケープしています(コードは省略)。
📰 出典:WordPress Developer Resources「show_user_profile」
includes/profile-fields.php の全文です。上の2つの抜粋のほか、プロフィール画面に入力欄を出す処理を含みます。
wp-content/plugins/curation-tools/includes/profile-fields.php の全文(115行・新規)
<?php
/**
* 著者プロフィールの追加項目(ユーザーメタ)。
*
* 肩書き・専門分野・プロフィールURLを「ユーザー > プロフィール」画面に追加し、
* 著者ボックス(blocks/author-box)で表示する。
*
* ここで show_in_rest を true にした項目は、REST API(/wp/v2/users)で誰でも読める。
* 公開ページに表示してよい項目だけを登録し、連絡先などの非公開情報は登録しない。
*
* @package Curation_Tools
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* 追加するプロフィール項目の定義。
*
* @return array<string, array{label: string, type: string, description: string}>
*/
function curation_tools_profile_fields() {
return array(
'curation_job_title' => array(
'label' => '肩書き',
'type' => 'text',
'description' => '例:編集長、Webエンジニア。著者ボックスに表示されます。',
),
'curation_expertise' => array(
'label' => '専門分野',
'type' => 'text',
'description' => '例:情報セキュリティ、社内システムの導入支援。実際の経験・資格に基づいて書いてください。',
),
'curation_profile_url' => array(
'label' => 'プロフィールURL',
'type' => 'url',
'description' => '経歴を確認できるページ(所属組織の紹介ページなど)。',
),
);
}
/**
* ユーザーメタを登録する(型・サニタイズ・編集権限・REST 公開)。
*/
function curation_tools_register_profile_meta() {
foreach ( curation_tools_profile_fields() as $key => $field ) {
register_meta(
'user',
$key,
array(
'type' => 'string',
'description' => $field['label'],
'single' => true,
'default' => '',
'show_in_rest' => true,
'sanitize_callback' => 'url' === $field['type'] ? 'esc_url_raw' : 'sanitize_text_field',
// 第3引数はメタを更新する対象のユーザーID。そのユーザーを編集できる人だけが更新できる。
'auth_callback' => static function ( $allowed, $meta_key, $user_id ) {
return current_user_can( 'edit_user', $user_id );
},
)
);
}
}
add_action( 'init', 'curation_tools_register_profile_meta' );
/**
* プロフィール画面に入力欄を表示する(自分のプロフィール・他のユーザーの編集の両方)。
*
* @param WP_User $user 表示中のユーザー。
*/
function curation_tools_render_profile_fields( $user ) {
?>
<h2>著者プロフィール(記事の著者ボックスに表示)</h2>
<table class="form-table" role="presentation">
<?php foreach ( curation_tools_profile_fields() as $key => $field ) : ?>
<tr>
<th><label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $field['label'] ); ?></label></th>
<td>
<input type="<?php echo esc_attr( $field['type'] ); ?>" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>"
value="<?php echo esc_attr( get_user_meta( $user->ID, $key, true ) ); ?>" class="regular-text" />
<p class="description"><?php echo esc_html( $field['description'] ); ?></p>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php
}
add_action( 'show_user_profile', 'curation_tools_render_profile_fields' );
add_action( 'edit_user_profile', 'curation_tools_render_profile_fields' );
/**
* プロフィール画面の保存時に追加項目を保存する。
*
* WordPress 本体がフォームの nonce(update-user_{ID})を確認した後に呼ばれるが、
* このフックは他の処理から呼ばれる可能性もあるため、nonce と権限をここでも確認する。
*
* @param int $user_id 保存対象のユーザーID。
*/
function curation_tools_save_profile_fields( $user_id ) {
check_admin_referer( 'update-user_' . $user_id );
if ( ! current_user_can( 'edit_user', $user_id ) ) {
return;
}
foreach ( array_keys( curation_tools_profile_fields() ) as $key ) {
if ( isset( $_POST[ $key ] ) ) {
// サニタイズは register_meta の sanitize_callback が update_user_meta 時に行う。
update_user_meta( $user_id, $key, wp_unslash( $_POST[ $key ] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
}
}
}
add_action( 'personal_options_update', 'curation_tools_save_profile_fields' );
add_action( 'edit_user_profile_update', 'curation_tools_save_profile_fields' );
監修者を記事ごとに選べるようにする
投稿メタを登録し、保存時に検証する
includes/meta.php(説明用の抜粋。全文はこの節の最後)
$auth = static function ( $allowed, $meta_key, $post_id ) {
return current_user_can( 'edit_post', $post_id );
};
register_post_meta(
'post',
'_curation_supervisor_id',
array(
'type' => 'integer',
'description' => '監修者のユーザーID(0 は監修者なし)',
'single' => true,
'default' => 0,
'show_in_rest' => true,
'sanitize_callback' => 'curation_tools_sanitize_supervisor_id',
'auth_callback' => $auth,
)
);
function curation_tools_sanitize_supervisor_id( $value ) {
$user_id = absint( $value );
if ( 0 === $user_id ) {
return 0;
}
$user = get_userdata( $user_id );
return ( $user && user_can( $user, 'edit_posts' ) ) ? $user_id : 0;
}
監修日(_curation_supervised_on)も同じように登録し、YYYY-MM-DD 形式の実在する日付だけを保存します。
- キーを
_で始める:「保護されたメタ」になり、管理画面の「カスタムフィールド」欄に表示されません。監修者の ID を書き手が直接書き換えることを防ぎます。 - 監修者として保存できるのは、投稿の編集権限を持つユーザーだけ:存在しないユーザーや購読者の ID が送られてきた場合は 0(監修者なし)にします。エディター以外の経路(REST API の直接呼び出しなど)でも同じ検証が働きます。
- 編集できるのは、その記事を編集できる人だけ:
auth_callbackでedit_postの権限を確認します。
📰 出典:WordPress Developer Resources「register_post_meta()」
includes/meta.php の全文です。監修日の登録、監修者を取り出す関数、次に作る「監修」パネルの JS を読み込んで監修者の候補を渡す処理(curation_tools_enqueue_supervisor_panel())も含みます。
wp-content/plugins/curation-tools/includes/meta.php の全文(144行・新規)
<?php
/**
* 投稿メタ: 監修者と監修日。
*
* 監修者は WordPress のユーザー(投稿の編集権限を持つ人)から選ぶ。
* 実際に内容を確認した人がいる記事にだけ設定する運用を前提にし、未設定の記事では何も表示しない。
*
* @package Curation_Tools
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* 監修者・監修日の投稿メタを登録する。
*
* キーを _ で始めると「保護されたメタ」になり、管理画面の「カスタムフィールド」欄には出ない。
* REST API(エディター)から更新できるよう、auth_callback で投稿の編集権限を確認する。
*/
function curation_tools_register_post_meta() {
$auth = static function ( $allowed, $meta_key, $post_id ) {
return current_user_can( 'edit_post', $post_id );
};
register_post_meta(
'post',
'_curation_supervisor_id',
array(
'type' => 'integer',
'description' => '監修者のユーザーID(0 は監修者なし)',
'single' => true,
'default' => 0,
'show_in_rest' => true,
'sanitize_callback' => 'curation_tools_sanitize_supervisor_id',
'auth_callback' => $auth,
)
);
register_post_meta(
'post',
'_curation_supervised_on',
array(
'type' => 'string',
'description' => '監修日(YYYY-MM-DD)',
'single' => true,
'default' => '',
'show_in_rest' => true,
'sanitize_callback' => 'curation_tools_sanitize_date',
'auth_callback' => $auth,
)
);
}
add_action( 'init', 'curation_tools_register_post_meta' );
/**
* 監修者IDを検証する。存在しないユーザーや、投稿の編集権限がないユーザーは 0(なし)にする。
*
* @param mixed $value 入力値。
* @return int
*/
function curation_tools_sanitize_supervisor_id( $value ) {
$user_id = absint( $value );
if ( 0 === $user_id ) {
return 0;
}
$user = get_userdata( $user_id );
return ( $user && user_can( $user, 'edit_posts' ) ) ? $user_id : 0;
}
/**
* YYYY-MM-DD 形式の実在する日付だけを通す。
*
* @param mixed $value 入力値。
* @return string
*/
function curation_tools_sanitize_date( $value ) {
$value = is_string( $value ) ? trim( $value ) : '';
$date = DateTimeImmutable::createFromFormat( '!Y-m-d', $value );
return ( $date && $date->format( 'Y-m-d' ) === $value ) ? $value : '';
}
/**
* 記事の監修者を返す。未設定・ユーザー削除済みなら null。
*
* @param int $post_id 投稿ID。
* @return WP_User|null
*/
function curation_tools_get_supervisor( $post_id ) {
$user_id = (int) get_post_meta( $post_id, '_curation_supervisor_id', true );
if ( $user_id <= 0 ) {
return null;
}
$user = get_userdata( $user_id );
return $user ? $user : null;
}
/**
* 投稿の編集画面に「監修」パネル(editor/supervisor-panel.js のビルド結果)を読み込む。
*
* 監修者の候補(投稿の編集権限を持つユーザーの ID と表示名)は PHP で用意して渡す。
* REST API の /wp/v2/users は、ユーザー一覧の権限(list_users)がない編集者には
* 記事を公開済みのユーザーしか返さないため。
*/
function curation_tools_enqueue_supervisor_panel() {
$screen = get_current_screen();
if ( ! $screen || 'post' !== $screen->base || 'post' !== $screen->post_type ) {
return;
}
$asset_file = CURATION_TOOLS_DIR . 'build/supervisor-panel.asset.php';
if ( ! file_exists( $asset_file ) ) {
return;
}
$asset = require $asset_file;
wp_enqueue_script(
'curation-tools-supervisor-panel',
CURATION_TOOLS_URL . 'build/supervisor-panel.js',
$asset['dependencies'],
$asset['version'],
true
);
$candidates = array();
foreach ( get_users(
array(
'capability' => 'edit_posts',
'orderby' => 'display_name',
'fields' => array( 'ID', 'display_name' ),
)
) as $user ) {
$candidates[] = array(
'id' => (int) $user->ID,
'name' => $user->display_name,
);
}
wp_add_inline_script(
'curation-tools-supervisor-panel',
'window.curationToolsSupervisorCandidates = ' . wp_json_encode( $candidates ) . ';',
'before'
);
}
add_action( 'enqueue_block_editor_assets', 'curation_tools_enqueue_supervisor_panel' );
エディターに「監修」パネルを追加する
投稿の編集画面の右側に入力欄を追加するには、PluginDocumentSettingPanel(=投稿の設定サイドバーにパネルを差し込む仕組み)を使います。
wp-content/plugins/curation-tools/editor/supervisor-panel.js(新規・全文)
/**
* 投稿の編集画面(右側の「投稿」タブ)に「監修」パネルを追加する。
*
* 監修者(ユーザー)と監修日を投稿メタ _curation_supervisor_id / _curation_supervised_on に保存する。
*/
import { Notice, SelectControl, TextControl } from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import { useEntityProp } from '@wordpress/core-data';
import {
PluginDocumentSettingPanel,
store as editorStore,
} from '@wordpress/editor';
import { registerPlugin } from '@wordpress/plugins';
function SupervisorPanel() {
const postType = useSelect(
( select ) => select( editorStore ).getCurrentPostType(),
[]
);
const [ meta, setMeta ] = useEntityProp( 'postType', postType, 'meta' );
if ( 'post' !== postType || ! meta ) {
return null;
}
const supervisorId = meta._curation_supervisor_id || 0;
const supervisedOn = meta._curation_supervised_on || '';
const candidates = window.curationToolsSupervisorCandidates || [];
return (
<PluginDocumentSettingPanel name="curation-supervisor" title="監修">
<SelectControl
__next40pxDefaultSize
__nextHasNoMarginBottom
label="監修者"
help="実際にこの記事の内容を確認した人だけを選びます。"
value={ String( supervisorId ) }
options={ [
{ label: '(監修者なし)', value: '0' },
...candidates.map( ( user ) => ( {
label: user.name,
value: String( user.id ),
} ) ),
] }
onChange={ ( value ) =>
setMeta( {
...meta,
_curation_supervisor_id: parseInt( value, 10 ) || 0,
} )
}
/>
{ supervisorId > 0 && (
<TextControl
__next40pxDefaultSize
__nextHasNoMarginBottom
label="監修日"
type="date"
value={ supervisedOn }
onChange={ ( value ) =>
setMeta( { ...meta, _curation_supervised_on: value } )
}
/>
) }
{ supervisorId > 0 && ! supervisedOn && (
<Notice status="warning" isDismissible={ false }>
監修日を入力してください。
</Notice>
) }
</PluginDocumentSettingPanel>
);
}
registerPlugin( 'curation-supervisor', { render: SupervisorPanel } );
📰 出典:Block Editor Handbook「PluginDocumentSettingPanel」
監修者の候補一覧は、REST API ではなく PHP 側で用意して渡しています(includes/meta.php の curation_tools_enqueue_supervisor_panel())。REST API のユーザー一覧は、ユーザー一覧の閲覧権限を持たない編集者には「記事を公開したことがあるユーザー」しか返さないため、まだ記事を書いていない監修者が候補に出てこないからです。候補は get_users() で「投稿の編集権限を持つユーザー」に絞り、ID と表示名だけを渡します。
このパネルはブロックではないため、第4回の npm run build の設定では自動でビルドされません。そこで、@wordpress/scripts の標準設定に1つエントリー(=ビルドの起点になるファイル)を足す webpack.config.js を置きました。
wp-content/plugins/curation-tools/webpack.config.js(新規・全文)
/*
* @wordpress/scripts の標準設定に、ブロック以外のエディター用 JS(監修パネル)を追加する。
*
* 標準設定は --webpack-src-dir(blocks/)の block.json からエントリーを自動で探す。
* ここではその結果に editor/ のパネル(監修)を足している。
*/
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
module.exports = {
...defaultConfig,
entry: {
...defaultConfig.entry(),
'supervisor-panel': './editor/supervisor-panel.js',
},
};
コーディング規約のチェック(npm run lint:js)の対象にも、editor/ と webpack.config.js を加えます。wp-content/plugins/curation-tools/package.json に次の変更を加えます(+ が追加、- が削除)。
--- a/wp-content/plugins/curation-tools/package.json
+++ b/wp-content/plugins/curation-tools/package.json
@@ -10,7 +10,7 @@
"scripts": {
"build": "wp-scripts build --webpack-src-dir=blocks --output-path=build",
"start": "wp-scripts start --webpack-src-dir=blocks --output-path=build",
- "lint:js": "wp-scripts lint-js blocks"
+ "lint:js": "wp-scripts lint-js blocks editor webpack.config.js"
},
"devDependencies": {
"@wordpress/scripts": "30.16.0"
著者ボックスを動的ブロックで表示する
表示には、第4回と同じ動的ブロック「著者ボックス」(curation-tools/author-box)を作りました。設定は「表示する人」(記事の著者/記事の監修者)の1つだけで、中身は公開ページの表示時に PHP で組み立てます。
wp-content/plugins/curation-tools/blocks/author-box/render.php(新規・全文)
<?php
/**
* 著者ボックス: 公開ページの表示(動的ブロック)。
*
* role = author … 記事の著者。著者アーカイブ(/author/<name>/)ではその著者。
* role = supervisor … 記事の監修者。監修者が設定されていない記事では何も出力しない。
*
* @package Curation_Tools
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$curation_role = ( isset( $attributes['role'] ) && 'supervisor' === $attributes['role'] ) ? 'supervisor' : 'author';
// アーカイブページでも postId(一覧の先頭記事)が渡されるため、「記事ページ」か「クエリーループの中」の
// ときだけ記事の情報として扱う。
$curation_in_loop = isset( $block->context['queryId'] );
$curation_for_post = is_singular() || $curation_in_loop;
$curation_post_id = ( $curation_for_post && isset( $block->context['postId'] ) ) ? (int) $block->context['postId'] : 0;
$curation_user = null;
if ( 'supervisor' === $curation_role ) {
$curation_user = $curation_post_id ? curation_tools_get_supervisor( $curation_post_id ) : null;
} elseif ( $curation_post_id ) {
$curation_user = get_userdata( (int) get_post_field( 'post_author', $curation_post_id ) );
} elseif ( is_author() ) {
$curation_user = get_queried_object();
}
if ( ! $curation_user instanceof WP_User ) {
return;
}
$curation_job = get_user_meta( $curation_user->ID, 'curation_job_title', true );
$curation_expertise = get_user_meta( $curation_user->ID, 'curation_expertise', true );
$curation_profile_url = get_user_meta( $curation_user->ID, 'curation_profile_url', true );
$curation_bio = get_the_author_meta( 'description', $curation_user->ID );
$curation_supervised = '';
if ( 'supervisor' === $curation_role ) {
$curation_date_value = (string) get_post_meta( $curation_post_id, '_curation_supervised_on', true );
$curation_date = DateTimeImmutable::createFromFormat( '!Y-m-d', $curation_date_value, new DateTimeZone( 'UTC' ) );
if ( $curation_date ) {
$curation_supervised = sprintf(
'<time datetime="%1$s">%2$s</time>',
esc_attr( $curation_date->format( 'Y-m-d' ) ),
esc_html( wp_date( get_option( 'date_format' ), $curation_date->getTimestamp(), new DateTimeZone( 'UTC' ) ) )
);
}
}
$curation_label = 'supervisor' === $curation_role ? 'この記事の監修者' : 'この記事を書いた人';
if ( 'author' === $curation_role && ! $curation_post_id ) {
$curation_label = '著者プロフィール';
}
?>
<aside <?php echo get_block_wrapper_attributes( array( 'class' => 'curation-author-box is-role-' . $curation_role ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> aria-label="<?php echo esc_attr( $curation_label ); ?>">
<p class="curation-author-box__label"><?php echo esc_html( $curation_label ); ?></p>
<p class="curation-author-box__name">
<a href="<?php echo esc_url( get_author_posts_url( $curation_user->ID ) ); ?>"><?php echo esc_html( $curation_user->display_name ); ?></a>
<?php if ( $curation_job ) : ?>
<span class="curation-author-box__job"><?php echo esc_html( $curation_job ); ?></span>
<?php endif; ?>
</p>
<?php if ( $curation_expertise ) : ?>
<p class="curation-author-box__meta">専門分野:<?php echo esc_html( $curation_expertise ); ?></p>
<?php endif; ?>
<?php if ( $curation_supervised ) : ?>
<p class="curation-author-box__meta">監修日:<?php echo $curation_supervised; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- 上で esc_attr / esc_html 済み。 ?></p>
<?php endif; ?>
<?php if ( $curation_bio ) : ?>
<p class="curation-author-box__bio"><?php echo nl2br( esc_html( $curation_bio ) ); ?></p>
<?php endif; ?>
<?php if ( $curation_profile_url ) : ?>
<p class="curation-author-box__meta"><a href="<?php echo esc_url( $curation_profile_url ); ?>" rel="noopener">経歴・所属の詳細(外部サイト)</a></p>
<?php endif; ?>
</aside>
block.json に "usesContext": [ "postId", "postType" ] と書くと、テンプレート上の位置に応じて「今表示している記事の ID」がブロックに渡されます(ブロックコンテキスト)。これにより、同じブロックを記事テンプレートにも著者アーカイブにも置けます。
📰 出典:Block Editor Handbook「Context」
後半では、名前(著者アーカイブへのリンク)、肩書き、専門分野、監修日、紹介文、プロフィールURLを、値があるものだけ esc_html() / esc_url() でエスケープして出力します。監修者が設定されていない記事では、監修者の枠自体を出力しません。
ブロックの残りのファイルです。block.json の usesContext と、属性 role(author / supervisor)がポイントです。エディターには「表示する人」を選ぶ設定欄と、置き場所が分かる簡単な表示だけを出します(名前などの中身は公開ページで表示)。
wp-content/plugins/curation-tools/blocks/author-box/block.json(新規・全文)
{
"$schema": "https://schemas.wp.org/wp/6.8/block.json",
"apiVersion": 3,
"name": "curation-tools/author-box",
"version": "0.6.0",
"title": "著者ボックス",
"category": "theme",
"icon": "id",
"description": "記事の著者、または監修者のプロフィール(名前・肩書き・専門分野・紹介文)を表示する。テンプレートに置いて使う。",
"keywords": [ "著者", "監修", "プロフィール" ],
"textdomain": "curation-tools",
"attributes": {
"role": {
"type": "string",
"enum": [ "author", "supervisor" ],
"default": "author"
}
},
"usesContext": [ "postId", "postType" ],
"supports": {
"html": false,
"reusable": false,
"spacing": {
"margin": true
}
},
"editorScript": "file:./index.js",
"style": "file:./style-index.css",
"render": "file:./render.php"
}
wp-content/plugins/curation-tools/blocks/author-box/index.js(新規・全文)
/**
* 著者ボックス: ブロックの登録(エディター用)。表示は render.php で行う。
*/
import { registerBlockType } from '@wordpress/blocks';
import metadata from './block.json';
import Edit from './edit';
import './style.css';
registerBlockType( metadata.name, {
edit: Edit,
} );
wp-content/plugins/curation-tools/blocks/author-box/edit.js(新規・全文)
/**
* 著者ボックス: エディターでは「どちらを表示する枠か」だけを示す。
*
* 実際の内容は記事と著者の設定で決まるため、公開ページ(render.php)で表示する。
*/
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
import { PanelBody, SelectControl } from '@wordpress/components';
export default function Edit( { attributes, setAttributes } ) {
const { role } = attributes;
const blockProps = useBlockProps( { className: 'curation-author-box' } );
return (
<>
<InspectorControls>
<PanelBody title="表示する人">
<SelectControl
__next40pxDefaultSize
__nextHasNoMarginBottom
label="表示する人"
value={ role }
options={ [
{ label: '記事の著者', value: 'author' },
{
label: '記事の監修者(設定がある記事のみ表示)',
value: 'supervisor',
},
] }
onChange={ ( value ) =>
setAttributes( { role: value } )
}
/>
</PanelBody>
</InspectorControls>
<aside { ...blockProps }>
<p className="curation-author-box__label">
{ 'supervisor' === role
? 'この記事の監修者(監修者が設定された記事でのみ表示)'
: 'この記事を書いた人' }
</p>
<p>
名前・肩書き・専門分野・紹介文は公開ページで表示されます。
</p>
</aside>
</>
);
}
wp-content/plugins/curation-tools/blocks/author-box/style.css(新規・全文)
/*
* 著者ボックス(フロントとエディターの両方に読み込まれる)。
*/
.wp-block-curation-tools-author-box {
padding: var(--wp--preset--spacing--30) var(--wp--preset--spacing--40);
border: 1px solid var(--wp--preset--color--accent-6, #ddd);
border-radius: 4px;
}
.wp-block-curation-tools-author-box > p {
margin-block: 0 var(--wp--preset--spacing--20);
}
.wp-block-curation-tools-author-box > p:last-child {
margin-bottom: 0;
}
.wp-block-curation-tools-author-box .curation-author-box__label {
color: var(--wp--preset--color--brand, #1a5fb4);
font-size: var(--wp--preset--font-size--small, 0.875rem);
font-weight: 700;
}
.wp-block-curation-tools-author-box .curation-author-box__name {
font-size: var(--wp--preset--font-size--large, 1.25rem);
font-weight: 700;
}
.wp-block-curation-tools-author-box .curation-author-box__job,
.wp-block-curation-tools-author-box .curation-author-box__meta {
color: var(--wp--preset--color--accent-4, #5f6670);
font-size: var(--wp--preset--font-size--small, 0.875rem);
font-weight: 400;
}
プラグイン本体で、2つのファイルの読み込みとブロックの登録を足し、バージョンを 0.6.0 にします。wp-content/plugins/curation-tools/curation-tools.php に次の変更を加えます(+ が追加、- が削除)。
--- a/wp-content/plugins/curation-tools/curation-tools.php
+++ b/wp-content/plugins/curation-tools/curation-tools.php
@@ -2,7 +2,7 @@
/**
* Plugin Name: Curation Tools
* Description: キュレーションメディア用の小さな機能群(引用元カード・ランキング・関連記事・構造化データなど)。連載の各回で機能を追加していく。
- * Version: 0.4.0
+ * Version: 0.6.0
* Requires at least: 6.8
* Requires PHP: 8.2
* Author: third-hero
@@ -17,7 +17,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
-define( 'CURATION_TOOLS_VERSION', '0.4.0' );
+define( 'CURATION_TOOLS_VERSION', '0.6.0' );
define( 'CURATION_TOOLS_FILE', __FILE__ );
define( 'CURATION_TOOLS_DIR', plugin_dir_path( __FILE__ ) );
define( 'CURATION_TOOLS_URL', plugin_dir_url( __FILE__ ) );
@@ -27,6 +27,8 @@ define( 'CURATION_TOOLS_URL', plugin_dir_url( __FILE__ ) );
* 機能ごとに includes/ 配下のファイルに分け、ここから読み込む。
*/
require_once CURATION_TOOLS_DIR . 'includes/taxonomy-feature.php';
+require_once CURATION_TOOLS_DIR . 'includes/profile-fields.php';
+require_once CURATION_TOOLS_DIR . 'includes/meta.php';
/**
* ブロックを登録する。
@@ -36,6 +38,7 @@ require_once CURATION_TOOLS_DIR . 'includes/taxonomy-feature.php';
*/
function curation_tools_register_blocks() {
register_block_type( CURATION_TOOLS_DIR . 'build/source-card' );
+ register_block_type( CURATION_TOOLS_DIR . 'build/author-box' );
}
add_action( 'init', 'curation_tools_register_blocks' );
テーマ側では、著者と監修者の2つのブロックをテンプレートパーツにまとめ、3つの記事テンプレートのタグ表示の下に置きました。
wp-content/themes/curation-child/parts/author-box.html(新規・全文)
<!-- wp:group {"style":{"spacing":{"margin":{"top":"var:preset|spacing|50"}}},"layout":{"type":"default"}} -->
<div class="wp-block-group" style="margin-top:var(--wp--preset--spacing--50)">
<!-- wp:curation-tools/author-box /-->
<!-- wp:curation-tools/author-box {"role":"supervisor","style":{"spacing":{"margin":{"top":"var:preset|spacing|30"}}}} /-->
</div>
<!-- /wp:group -->
3つの記事テンプレートのタグ表示の下にパーツを置き、theme.json にパーツを登録します。
wp-content/themes/curation-child/templates/single.html に次の変更を加えます(+ が追加、- が削除)。
--- a/wp-content/themes/curation-child/templates/single.html
+++ b/wp-content/themes/curation-child/templates/single.html
@@ -14,6 +14,8 @@
<!-- wp:post-terms {"term":"post_tag","prefix":"タグ:","style":{"spacing":{"margin":{"top":"var:preset|spacing|50"}}},"fontSize":"small"} /-->
+ <!-- wp:template-part {"slug":"author-box"} /-->
+
<!-- wp:pattern {"slug":"twentytwentyfive/post-navigation"} /-->
</main>
<!-- /wp:group -->
wp-content/themes/curation-child/templates/single-matome.html に次の変更を加えます(+ が追加、- が削除)。
--- a/wp-content/themes/curation-child/templates/single-matome.html
+++ b/wp-content/themes/curation-child/templates/single-matome.html
@@ -23,6 +23,8 @@
<!-- wp:post-terms {"term":"post_tag","prefix":"タグ:","style":{"spacing":{"margin":{"top":"var:preset|spacing|50"}}},"fontSize":"small"} /-->
+ <!-- wp:template-part {"slug":"author-box"} /-->
+
<!-- wp:pattern {"slug":"twentytwentyfive/post-navigation"} /-->
</main>
<!-- /wp:group -->
wp-content/themes/curation-child/templates/single-ranking.html に次の変更を加えます(+ が追加、- が削除)。
--- a/wp-content/themes/curation-child/templates/single-ranking.html
+++ b/wp-content/themes/curation-child/templates/single-ranking.html
@@ -23,6 +23,8 @@
<!-- wp:post-terms {"term":"post_tag","prefix":"タグ:","style":{"spacing":{"margin":{"top":"var:preset|spacing|50"}}},"fontSize":"small"} /-->
+ <!-- wp:template-part {"slug":"author-box"} /-->
+
<!-- wp:pattern {"slug":"twentytwentyfive/post-navigation"} /-->
</main>
<!-- /wp:group -->
wp-content/themes/curation-child/theme.json に次の変更を加えます(+ が追加、- が削除)。
--- a/wp-content/themes/curation-child/theme.json
+++ b/wp-content/themes/curation-child/theme.json
@@ -80,6 +80,11 @@
"name": "post-meta",
"title": "記事のメタ情報(カテゴリ・特集・日付)",
"area": "uncategorized"
+ },
+ {
+ "name": "author-box",
+ "title": "著者・監修者のプロフィール",
+ "area": "uncategorized"
}
],
"styles": {
wp-content/themes/curation-child/style.css に次の変更を加えます(+ が追加、- が削除)。
--- a/wp-content/themes/curation-child/style.css
+++ b/wp-content/themes/curation-child/style.css
@@ -4,7 +4,7 @@ Theme URI: https://example.com/
Description: 「WordPressでキュレーションメディアを作る」連載用の Twenty Twenty-Five 子テーマ。
Author: third-hero
Template: twentytwentyfive
-Version: 0.5.0
+Version: 0.6.0
Requires at least: 6.8
Tested up to: 6.8
Requires PHP: 8.2
著者アーカイブ(templates/author.html)は、第2回の特集一覧と同じ構成で、ページ上部に著者ボックスを置いています。
wp-content/themes/curation-child/templates/author.html(新規・全文)
<!-- wp:template-part {"slug":"header"} /-->
<!-- wp:group {"tagName":"main","style":{"spacing":{"margin":{"top":"var:preset|spacing|60"}}},"layout":{"type":"constrained"}} -->
<main class="wp-block-group" style="margin-top:var(--wp--preset--spacing--60)">
<!-- wp:query-title {"type":"archive","showPrefix":false} /-->
<!-- wp:curation-tools/author-box /-->
<!-- wp:heading {"style":{"spacing":{"margin":{"top":"var:preset|spacing|50"}}},"fontSize":"large"} -->
<h2 class="wp-block-heading has-large-font-size" style="margin-top:var(--wp--preset--spacing--50)">この著者の記事</h2>
<!-- /wp:heading -->
<!-- wp:query {"query":{"perPage":10,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","inherit":true},"layout":{"type":"default"}} -->
<div class="wp-block-query">
<!-- wp:post-template {"layout":{"type":"default"}} -->
<!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|40","bottom":"var:preset|spacing|40"}},"border":{"bottom":{"color":"var:preset|color|accent-6","width":"1px"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group" style="border-bottom-color:var(--wp--preset--color--accent-6);border-bottom-width:1px;padding-top:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40)">
<!-- wp:post-terms {"term":"category","fontSize":"small"} /-->
<!-- wp:post-title {"isLink":true,"fontSize":"large"} /-->
<!-- wp:post-date {"fontSize":"small"} /-->
</div>
<!-- /wp:group -->
<!-- /wp:post-template -->
<!-- wp:query-no-results -->
<!-- wp:paragraph -->
<p>この著者の記事はまだありません。</p>
<!-- /wp:paragraph -->
<!-- /wp:query-no-results -->
<!-- wp:query-pagination {"layout":{"type":"flex","justifyContent":"space-between"},"style":{"spacing":{"margin":{"top":"var:preset|spacing|50"}}}} -->
<!-- wp:query-pagination-previous {"label":"前へ"} /-->
<!-- wp:query-pagination-numbers /-->
<!-- wp:query-pagination-next {"label":"次へ"} /-->
<!-- /wp:query-pagination -->
</div>
<!-- /wp:query -->
</main>
<!-- /wp:group -->
<!-- wp:template-part {"slug":"footer"} /-->
プロフィール画像(アバター)は表示していません。WordPress 標準のアバターは外部サービス(Gravatar)の画像を読み込むため、使う場合はプライバシーポリシーへの記載を含めて運用で判断してください。
動作確認の方法
第0回・第2回の手順の後、プラグインをビルド(プラグインのフォルダで npm run build)してから確認しました(筆者の環境で確認済みです)。第2回の seed-terms.sh で作ったサンプル記事は、WP-CLI で作ったため著者が未設定(0)です。著者ボックスを確かめる記事には、先に著者を設定します。監修者用のユーザーも作ります。
# 確認に使う記事の ID(第2回のサンプル記事)
docker compose run --rm wpcli wp post list --name=genai-meeting-notes --field=ID
docker compose run --rm wpcli wp post update <記事ID> --post_author=1
# 肩書きと監修者
docker compose run --rm wpcli wp user meta update 1 curation_job_title '編集長'
docker compose run --rm wpcli wp user create kanshu kanshu@example.com --role=editor --display_name='監修 太郎' --porcelain
docker compose run --rm wpcli wp post meta update <記事ID> _curation_supervisor_id <監修者のユーザーID>
docker compose run --rm wpcli wp post meta update <記事ID> _curation_supervised_on 2025-08-01
curl -s http://localhost:8088/genai-meeting-notes/ | grep -o 'aria-label="この記事[^"]*"'
curl -s http://localhost:8088/wp-json/wp/v2/users/1
- 記事に「この記事を書いた人」のボックスが表示され、肩書き「編集長」と紹介文が出る
- 監修者を設定した記事でのみ「この記事の監修者」のボックスが表示され、肩書き・専門分野・監修日・プロフィールURLが出る。設定していない記事には出ない
/wp-json/wp/v2/users/1は認証なしで id・name・url・description・link・slug・avatar_urls と、登録した3つのメタだけを返し、メールアドレスは含まれない(slug については「つまずきやすい点」を参照)- 監修者に購読者の ID や存在しないユーザーを指定しても 0(なし)として保存され、存在しない日付(2025-02-30)の監修日は保存されない
- 寄稿者が他人の記事の監修者を REST API で変更しようとすると 403、編集者が他のユーザーのプロフィール項目を変更しようとすると 403
- プロフィールURLに
javascript:を入れると空で保存される - 著者アーカイブ(
/author/<ユーザー名>/)が 200 で、上部に「著者プロフィール」が表示される - エディター(ヘッドレスブラウザで確認)で「監修」パネルが表示され、監修者を選ぶと監修日の入力欄と警告が出て、日付を入れると警告が消え、保存後に投稿メタに反映される
つまずきやすい点・セキュリティ上の注意
- REST API に出る項目を意識する:
show_in_restを付けたユーザーメタは公開情報になります。「管理画面で入力できる=社内だけの情報」ではない点に注意してください。 - ログイン名に近い値が URL と REST API に出る:著者アーカイブの URL と REST API の slug には、ユーザーのスラッグが使われます。スラッグの初期値はログイン名から作られるため、ログイン名とは別の値にしておく運用が安心です。
- 監修者のアカウント管理:監修者を WordPress のユーザーにする場合、社外の専門家にもアカウントを発行することになります。権限は最小限(寄稿者など)にし、契約終了時の扱いを決めておきます。
発注者向けメモ:監修者表示は「監修した事実」とセットで依頼する
著者・監修者の表示そのものは、今回のように比較的小さな実装で実現できます。難しいのは運用です。
- 監修者を表示するのは、実際に監修した記事だけにする:名前だけを借りる「名義貸し」は、読者の信頼を大きく損ないます。監修の範囲(全文を確認したのか、専門部分だけか)と監修日を記録する運用を決めてください。
- 表示すれば検索順位が上がる、というものではない:Google は E-E-A-T 自体をランキング要因ではないと説明しています。著者表示は読者に判断材料を渡すためのものと考えましょう。
- 経歴の正確さと更新:肩書き・資格・所属は本人の確認を取り、変わったときに誰が更新するかを決めます。
- 社外の監修者の個人情報:公開する項目(名前・肩書き・所属先のURLなど)について本人の同意を取り、公開しない情報はシステムにも登録しない、という線引きをしておきます。
工数やリスクが増えるのは、監修者をユーザーではなく独自の管理画面で管理したい場合や、1記事に複数の監修者を設定したい場合、監修の依頼・承認のワークフローまでシステム化したい場合です。
打ち合わせでは、次のように聞いてみてください。
- 「著者・監修者のプロフィールのうち、REST API などで外部から読める項目はどれですか?」
- 「監修者を設定していない記事では、監修者欄はどう表示されますか?(空欄ではなく、非表示になりますか)」
- 「社外の監修者のアカウントにはどの権限を付けますか? 契約終了時の手順はありますか?」
まとめと次回予告
第6回では、著者・監修者のプロフィールを登録・表示する仕組みを作りました。
- E-E-A-T は Google の品質の考え方で、Google 自身がランキングに直接影響する要因ではないと説明している
- 人に付く情報(肩書き・専門分野)はユーザーメタ、記事ごとの情報(監修者・監修日)は投稿メタに分ける
register_meta()で型・サニタイズ・権限を決め、show_in_restの項目は公開情報として扱う- 監修者はエディターのサイドバーから選び、保存時に「投稿の編集権限を持つユーザーか」を検証する
- 表示は動的ブロック「著者ボックス」をテンプレートパーツに置き、監修者がいない記事では出さない
次回は「人気記事ランキングと関連記事を小さなプラグインで作る」です。閲覧数をページキャッシュと両立する形で集計し、期間別のランキングと、タグ・特集をもとにした関連記事を表示します。
この連載の記事一覧
この記事は連載「WordPressで作るキュレーションメディア」の1回です。連載のほかの回は次のとおりです(連載の一覧ページ)。
- 【WordPressで作るキュレーションメディア 第0回】キュレーションメディアの要件と「低品質まとめ」の教訓 ― Docker で WordPress 6.8 の土台を作る
- 【WordPressで作るキュレーションメディア 第1回】theme.json でデザイントークンを定義する(子テーマの基本)
- 【WordPressで作るキュレーションメディア 第2回】カテゴリ・タグ・「特集」― タクソノミー設計
- 【WordPressで作るキュレーションメディア 第3回】記事・まとめ・ランキングのテンプレートとパターン
- 【WordPressで作るキュレーションメディア 第4回】「引用元カード」ブロック ― 著作権法第32条の引用を仕組みで守る
- 【WordPressで作るキュレーションメディア 第5回】「まとめリスト」と「比較表」をパターンとブロックスタイルで作る
- 【WordPressで作るキュレーションメディア 第6回】著者・監修者プロフィールを表示する(E-E-A-T の考え方)(この記事)
- 【WordPressで作るキュレーションメディア 第7回】人気記事ランキングと関連記事を小さなプラグインで作る
- 【WordPressで作るキュレーションメディア 第8回】目次と構造化データ(JSON-LD: Article / BreadcrumbList / ItemList)
- 【WordPressで作るキュレーションメディア 第9回】OGP・SNS カードと「広告・PR表記」― ステマ規制への対応
- 【WordPressで作るキュレーションメディア 第10回】表示速度の改善 ― 画像サイズ・キャッシュ・計測
- 【WordPressで作るキュレーションメディア 第11回】権限・編集フロー・運用 ― 下書きレビュー、バックアップ、更新










コメント
コメント一覧 (1件)
[…] 前回の第6回では、著者・監修者のプロフィールを表示する仕組みを作りました。第7回の今回は、人気記事ランキングと関連記事をプラグインに追加します。 […]