function.php
以下は<main>タグ内のテキストを取得する。
function includeFile($atts) {
if (isset($atts['url'])) {
$url = $atts['url'];
$html = file_get_contents($url);
if (preg_match("/<main[^>]*>(.*?)<\/main>/is", $html, $body)) {
return $body[1];
} else {
return "(準備中)";
}
}
}
add_shortcode('include', 'includeFile');
page
[include url='http://nyanko.jp/home/?p=334']
