/* -------------------------------------------------- 行田市ライブ状況カード(診断モード付き) 使い方: [gyoda_live_status type="sakura"] -------------------------------------------------- */ function gyoda_live_status_shortcode($atts) { // 現在のページIDを強制的に取得 $current_id = get_the_ID(); // 引数取得 $atts = shortcode_atts(array( 'type' => 'sakura', ), $atts); $type = $atts['type']; // ▼▼▼ 診断モード(管理者のみ表示) ▼▼▼ if (current_user_can('administrator')) { $debug_info = ""; $field_name = 'show_' . $type; $is_show = get_field($field_name, $current_id); // データが取れていない場合のメッセージ作成 if ($is_show === null) { $debug_info = "
"; $debug_info .= "⚠️ エラー診断:
"; $debug_info .= "現在のページID: $current_id
"; $debug_info .= "探しているフィールド名: $field_name
"; $debug_info .= "結果: データが見つかりません (NULL)
"; $debug_info .= "対策: ACFのフィールド名が合っているか、このページにデータが入力・保存されているか確認してください。"; $debug_info .= "
"; echo $debug_info; // 画面に出力 } elseif ($is_show == false) { // スイッチがOFFの場合 $debug_info = "
"; $debug_info .= "ℹ️ 診断: ID:$current_id / $field_name は OFF になっています。"; $debug_info .= "
"; echo $debug_info; return ''; // OFFなら終了 } } // ▲▲▲ 診断モード終了 ▲▲▲ // 1. 表示スイッチチェック if (!get_field('show_' . $type, $current_id)) { return ''; } // 2. データ取得 $status = get_field('status_' . $type, $current_id); $text = get_field('text_' . $type, $current_id); $link = get_field('link_' . $type, $current_id); // タイトル定義 $meta_data = [ 'sakura' => ['title' => '桜', 'icon' => '🌸'], 'lotus' => ['title' => '古代蓮', 'icon' => '🪷'], 'hanachozu' => ['title' => '花手水', 'icon' => '🌼'] ]; $title = isset($meta_data[$type]) ? $meta_data[$type]['title'] : 'イベント'; $icon = isset($meta_data[$type]) ? $meta_data[$type]['icon'] : '✨'; // ステータスラベル $status_labels = [ 'wait' => '咲き始め', 'good' => '見頃', 'end' => '終了' ]; $status_label = isset($status_labels[$status]) ? $status_labels[$status] : ''; ob_start(); ?>

h3 { border-bottom: solid 1px #aaa; margin: 40px 0 40px 0; font-size: 24px; }

堀口屋