福岡・久留米のホームページ制作|猫壱屋

SNS埋め込みでSEO対策

2026-02-16

自サイトには「てがろぐ」を埋め込んでるので有効利用

function.phpには


function get_tegalog_last_updated() {

    $rss_content = @file_get_contents('※ディレクトリ');

    if (!$rss_content) return date('Y年n月j日'); // ★今日の日付を返す

    $rss_content = mb_convert_encoding($rss_content, 'UTF-8', 'auto');

    $rss = simplexml_load_string($rss_content);

    $latest_item = $rss->channel->item[0] ?? null;

    if ($latest_item && isset($latest_item->pubDate)) {

        return date('Y年n月j日', strtotime((string)$latest_item->pubDate));

    }

    return date('Y年n月j日'); // ★今日の日付を返す

}

index.phpには

<div class="last-updated">

    <p>最終更新日:<?php echo get_tegalog_last_updated(); ?></p>

</div>

こちらはCGIだったから簡単に済んだのだが
インスタとかはプラグインのほうが簡単かも。

一覧に戻る