_yoast_display_notifications()


WordPressの関数_yoast_display_notifications()は、Yoast SEOプラグインで通知を表示するために使用されます。

構文

_yoast_display_notifications();

例 1. 通知の表示

Yoast SEOの通知を画面に表示します。

<?php _yoast_display_notifications(); ?>

例 2. 通知をカスタムフックで実行

カスタムフック内で通知を表示します。

<?php
add_action( 'admin_notices', '_yoast_display_notifications' );
?>

例 3. 特定条件下で通知を非表示

現在のページが「投稿」ページの場合にのみ通知を表示します。

<?php
if ( is_singular( 'post' ) ) {
    _yoast_display_notifications();
}
?>

例 4. 通知の出力をバッファリング

通知の出力をキャプチャし、変数に格納します。

<?php
ob_start();
_yoast_display_notifications();
$notifications = ob_get_clean();
echo $notifications;
?>

例 5. 特定の管理画面で通知を表示

「投稿一覧」画面でのみ通知を表示します。

<?php
if ( 'edit.php' === $GLOBALS['pagenow'] ) {
    _yoast_display_notifications();
}
?>

注意事項

  • _yoast_display_notifications()は内部関数であり、外部での直接使用は推奨されません。
  • この関数はYoast SEOプラグインが有効化されている場合にのみ動作します。
  • 通知の内容や動作はYoast SEOプラグインの設定に依存します。