// 3. アクセスされた瞬間に「中身が入った固定ページ」として自動生成・保存する仕組み(★強化版) function auto_generate_calculator_page() { $calc_type = get_query_var('calc_type'); $val1 = floatval(get_query_var('calc_val1')); $val2 = floatval(get_query_var('calc_val2')); if ( ! in_array($calc_type, ['tsubo_sqm', 'sqm_tsubo', 'rect_sqm']) || $val1 <= 0 ) { return; } $slug = ''; $title = ''; $content = ''; // --- 1. 坪 → 平米 のHTML生成 --- if ( $calc_type === 'tsubo_sqm' ) { $slug = 'tsubo-to-sqm-' . $val1; $title = $val1 . '坪は何平米(㎡)?自動計算結果と広さの目安'; $sqm = round($val1 * 3.305785, 2); $tatami = round($sqm / 1.62, 1); $cars = floor($sqm / 15); $build = round($sqm * 0.6, 1); $floor = round($sqm * 1.0, 1); $content = "

{$val1}坪 ⇔ 平米(㎡)自動計算

計算結果
約 {$sqm} ㎡

{$val1}坪の広さイメージ・建築目安

"; // --- 2. 平米 → 坪 のHTML生成 --- } elseif ( $calc_type === 'sqm_tsubo' ) { $slug = 'sqm-to-tsubo-' . $val1; $title = $val1 . '平米(㎡)は何坪?自動計算結果と広さの目安'; $tsubo = round($val1 * 0.3025, 2); $tatami = round($val1 / 1.62, 1); $content = "

{$val1}㎡ ⇔ 坪 自動計算

計算結果
約 {$tsubo} 坪
畳に直すと:約 {$tatami} 帖
"; // --- 3. 縦横 → 平米 のHTML生成 --- } elseif ( $calc_type === 'rect_sqm' && $val2 > 0 ) { $slug = 'rect-to-sqm-' . $val1 . '-' . $val2; $title = '縦' . $val1 . 'm×横' . $val2 . 'mの面積・坪数計算結果'; $sqm = round($val1 * $val2, 2); $tsubo = round($sqm * 0.3025, 2); $cross = round($sqm * 3.5, 1); $content = "

縦 {$val1}m × 横 {$val2}m の面積

約 {$sqm} ㎡
(約 {$tsubo} 坪)

DIY資材の目安

🧱 壁紙(クロス)必要量目安: 約 {$cross} m(※天井高2.4m想定)

"; } // --- データベースへの書き込み処理 --- if ( $slug && ! get_page_by_path( $slug ) ) { $post_data = array( 'post_title' => $title, 'post_name' => $slug, 'post_content' => $content, // ★本文(HTML)をセットして保存! 'post_status' => 'publish', 'post_type' => 'page', 'comment_status' => 'closed', 'ping_status' => 'closed', ); wp_insert_post( $post_data ); } } add_action('template_redirect', 'auto_generate_calculator_page'); ページが見つかりませんでした – 坪から平米(㎡)を計算

ここを指しているリンクに誤りがあったようです。検索してみるのはいかがですか ?

上部へスクロール