{"id":207,"date":"2019-05-19T10:12:35","date_gmt":"2019-05-19T01:12:35","guid":{"rendered":"https:\/\/blog.hgrs.me\/?p=207"},"modified":"2019-05-19T06:08:02","modified_gmt":"2019-05-18T21:08:02","slug":"wordpress%e3%81%ae%e8%a8%98%e4%ba%8b%e4%b8%8a%e3%81%ab%e3%82%a2%e3%82%a4%e3%82%ad%e3%83%a3%e3%83%83%e3%83%81%e3%82%92javascript%e3%81%a7%e8%87%aa%e5%8b%95%e6%8c%bf%e5%85%a5%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/blog.hgrs.me\/archives\/207.html","title":{"rendered":"WordPress\u306e\u8a18\u4e8b\u4e0a\u306b\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1\u3092JavaScript\u3067\u81ea\u52d5\u633f\u5165\u3059\u308b"},"content":{"rendered":"

\u306f\u3058\u3081\u306b<\/h2>\n

\u50d5\u306e\u4f7f\u3063\u3066\u308b\u30c6\u30fc\u30deNishiki<\/a>\u3067\u306f\u6295\u7a3f\u30da\u30fc\u30b8\u306b\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1\u304c\u8868\u793a\u3055\u308c\u307e\u305b\u3093\u3002\u306a\u306e\u3067\u8a18\u4e8b\u306e\u4e0a\u306b\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1\u304c\u8868\u793a\u3055\u308c\u308b\u3088\u3046\u306b\u5909\u66f4\u3057\u3066\u307f\u307e\u3057\u305f\u3001JavaScript<\/strong>\u3067\u3002PHP\u3058\u3083\u306a\u304f\u3066\u3001JavaScript<\/strong>\u3067\u3002<\/p>\n

\u306a\u3093\u3067JavaScript\uff1f<\/h2>\n

WordPress\u3068\u3044\u3048\u3070PHP\u3067\u3059\u3088\u306d\u3002\u78ba\u304b\u306b\u3001\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1\u306e\u8ffd\u52a0\u306f\u30c6\u30fc\u30de\u306ePHP\u3092\u3044\u3058\u308c\u3070\u8ffd\u52a0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n

\u3067\u3082\u50d5\u306f\u307e\u3060\u30d6\u30ed\u30b0\u3092\u59cb\u3081\u305f\u3070\u304b\u308a\u3067\u3001\u4eca\u5f8c\u30c6\u30fc\u30de\u3092\u5909\u3048\u3066\u3057\u307e\u3046\u304b\u3082\u3057\u308c\u306a\u3044\u306e\u3067\u3001\u3042\u307e\u308a\u30c6\u30fc\u30de\u306b\u4f9d\u5b58\u3057\u305f\u66f8\u304d\u65b9\u3092\u3057\u305f\u304f\u306a\u304b\u3063\u305f\u306e\u3067\u3059\u3002<\/p>\n

\u305d\u306e\u305f\u3081\u3001\u5225\u306e\u65b9\u6cd5\u3067\u8ffd\u52a0\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3057\u305f\u3002\u305d\u3053\u3067\u8a18\u4e8b\u306e\u4e0a\u4e0b\u306bHTML\u3092\u633f\u5165\u3067\u304d\u308b\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f7f\u7528\u3057\u3066\u5b9f\u73fe\u3057\u307e\u3057\u305f\u3002<\/p>\n

HTML\u304c\u66f8\u3051\u308b\u3068\u3044\u3046\u3053\u3068\u306f<script><\/script><\/code>\u30bf\u30b0\u3092\u5229\u7528\u3057\u3066JavaScript\u304c\u66f8\u3051\u307e\u3059\u3002\u306a\u306e\u3067JavaScript\u3067\u5b9f\u73fe\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n

\u4e8b\u524d\u6e96\u5099<\/h2>\n

\u8a18\u4e8b\u306e\u4e0a\u4e0b\u306bHTML\u3092\u8ffd\u52a0\u3059\u308b\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u5165\u308c\u307e\u3059\u3002<\/p>\n

PRyC WP: Add custom content to post and page (top\/bottom)<\/a><\/p>\n

\u8ffd\u52a0\u30b3\u30fc\u30c9\u306e\u8a18\u5165<\/h2>\n

\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u8a2d\u5b9a\u304b\u3089\u8a18\u4e8b\u4e0a\u306e\u30b3\u30fc\u30c9\u306b\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u66f8\u304d\u52a0\u3048\u307e\u3059\uff08\u64cd\u4f5c\u306f\u56f3\u3092\u53c2\u7167\uff09\u3002<\/p>\n

\u6ce8\u610f\u70b9\u3068\u3057\u3066\u306f\u3001\u4e00\u884c\u76ee\u306e<img><\/code>\u30bf\u30b0\u306esrc<\/code>\u306f\u81ea\u5206\u306e\u597d\u304d\u306a\u8aad\u307f\u8fbc\u307f\u4e2d\u306e\u753b\u50cf\u3092\u8a2d\u5b9a\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n

<img name="top_ogp_image" src="https:\/\/example.com\/path\/to\/loading.png">\n<script type="text\/javascript">\n    var metas = document.head.children;\n    for(var i=0; i<metas.length; i++){\n        var property = metas[i].getAttribute('property');\n        if(property === 'og:image'){\n            var imagePath = metas[i].getAttribute('content');\n            document.top_ogp_image.src = imagePath;\n        }\n    }\n<\/script><\/code><\/pre>\n

\"JavaScript\u306e\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1\"<\/p>\n

\u4ed5\u7d44\u307f\u306e\u89e3\u8aac<\/h2>\n

JavaScript\u304b\u3089DOM\u3092\u4f7f\u7528\u3057\u3001<meata><\/code>\u30bf\u30b0\u306b\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308bOGP\u753b\u50cf\u3092\u8aad\u307f\u53d6\u3063\u3066\u304d\u307e\u3059\u3002<\/p>\n

\u305f\u3060\u7279\u5b9a\u306e<meta><\/code>\u30bf\u30b0\u3092\u4e00\u767a\u3067\u53d6\u3063\u3066\u304f\u308b\u3053\u3068\u304c\u3067\u304d\u306a\u3044\u305f\u3081\u3001\u307e\u305adocument.head.children<\/code>\u3092\u5229\u7528\u3057\u3001<head><\/head><\/code>\u306e\u5168\u3066\u306e\u5b50\u8981\u7d20\u3092\u53d6\u3063\u3066\u304d\u307e\u3059\u3002\u305d\u3053\u304b\u3089OGP\u753b\u50cf\uff08property<\/code>\u304cog:image<\/code>\u306b\u306a\u3063\u3066\u3044\u308b\u3082\u306e\uff09\u3092\u629c\u304d\u51fa\u3057\u307e\u3059\u3002<\/p>\n

\u305d\u3057\u3066OGP\u753b\u50cf\u3067\u8aad\u307f\u8fbc\u3093\u3067\u3044\u308b\u753b\u50cf\u3092\u3042\u3089\u304b\u3058\u3081\u7528\u610f\u3057\u305f<img><\/code>\u30bf\u30b0\u306esrc<\/code>\u3068\u3057\u3066\u5272\u308a\u5f53\u3066\u307e\u3059\u3002<\/p>\n

\u3053\u3046\u3059\u308b\u3053\u3068\u3067\u3001JavaScript\u3092\u4f7f\u3063\u3066\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1\u753b\u50cf\u306e\u81ea\u52d5\u633f\u5165\u3092\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n

\u30e1\u30ea\u30c3\u30c8<\/h2>\n

\u30c6\u30fc\u30de\u306b\u4f9d\u5b58\u3057\u306a\u3044<\/h3>\n

\u3055\u3063\u304d\u3082\u66f8\u304d\u307e\u3057\u305f\u306d\u3002\u30c6\u30fc\u30de\u3092\u5909\u3048\u305f\u308a\u3057\u305f\u6642\u306b\u308f\u3056\u308f\u3056\u79fb\u884c\u306e\u5fc5\u8981\u304c\u3042\u308a\u307e\u305b\u3093\u3002\u5358\u7d14\u306b\u8a18\u4e8b\u4e0a\u4e0b\u306bHTML\u3092\u66f8\u304d\u52a0\u3048\u308b\u30d7\u30e9\u30b0\u30a4\u30f3\u306a\u306e\u3067\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u6027\u3082\u9ad8\u3044\u3067\u3059\u3002<\/p>\n

\u4e00\u62ec\u7ba1\u7406\u304c\u3067\u304d\u308b<\/h3>\n

\u4f8b\u3048\u3070\u300c\u3084\u3063\u3071\u308a\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1\u6d88\u305d\u300d\u300c\u8868\u793a\u30b5\u30a4\u30ba\/\u5834\u6240\u3092\u5909\u3048\u3088\u300d\u3068\u3044\u3063\u305f\u3053\u3068\u304c\u4e00\u62ec\u3067\u64cd\u4f5c\u3067\u304d\u307e\u3059\u3002\u307e\u3042\u3001\u3053\u308c\u306fPHP\u3067\u3082\u540c\u3058\u3067\u3059\u304c\u2026<\/p>\n

\u305f\u3060\u3001\u3053\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u306fID\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u7279\u5b9a\u306e\u8a18\u4e8b\u306b\u306f\u8868\u793a\u3057\u306a\u3044\u3068\u3044\u3063\u305f\u6307\u5b9a\u304c\u3067\u304d\u308b\u306e\u306f\u826f\u3044\u70b9\u3067\u3059\u306d\u3002<\/p>\n

\u30c7\u30e1\u30ea\u30c3\u30c8<\/h2>\n

\u8aad\u307f\u8fbc\u307f\u304c\u767a\u751f\u3059\u308b<\/h3>\n

JavaScript\u3067\u66f8\u3044\u3066\u3044\u308b\u306e\u3067\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30b5\u30a4\u30c9\uff08\u30d6\u30e9\u30a6\u30b6\uff09\u3067\u753b\u50cf\u306e\u5272\u308a\u5f53\u3066\u304c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u3001\u30b5\u30fc\u30d0\u30b5\u30a4\u30c9\u306ePHP\u3068\u9055\u3063\u3066\u3001\u30da\u30fc\u30b8\u3092\u8aad\u307f\u8fbc\u3093\u3060\u5f8c\u306b\u753b\u50cf\u3092\u63a2\u3059\u306e\u3067\u3001\u30bf\u30a4\u30e0\u30e9\u30b0\u304c\u751f\u3058\u307e\u3059\u3002\u3053\u306e\u30bf\u30a4\u30e0\u30e9\u30b0\u304c\u753b\u50cf\u8aad\u307f\u8fbc\u307f\u306e\u9045\u5ef6\u306e\u539f\u56e0\u3067\u3059\u3002<\/p>\n

\u304a\u308f\u308a\u306b<\/h2>\n

\u3061\u3087\u3063\u3068\u7279\u6b8a\u306a\u65b9\u6cd5\u3067\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1\u3092\u6307\u5b9a\u3057\u307e\u3057\u305f\u304c\u3001\u81ea\u7531\u5ea6\u304c\u9ad8\u3044\u306e\u3067\u826f\u3044\u3067\u3059\u306d\u3002\u3044\u3064\u8868\u793a\u3092\u6d88\u3059\u304b\u308f\u304b\u308a\u307e\u305b\u3093\u304c\u7b11\u3002<\/p>\n

\u307b\u3093\u3068\u306fPHP\u304c\u5acc\u3044\u306a\u306e\u3067\u66f8\u304d\u305f\u304f\u306a\u304b\u3063\u305f\u3060\u3051\u3002<\/del><\/p>\n","protected":false},"excerpt":{"rendered":"

\u306f\u3058\u3081\u306b \u50d5\u306e\u4f7f\u3063\u3066\u308b\u30c6\u30fc\u30deNishiki\u3067\u306f\u6295\u7a3f\u30da\u30fc\u30b8\u306b\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1\u304c\u8868\u793a\u3055\u308c\u307e\u305b\u3093\u3002\u306a\u306e\u3067\u8a18\u4e8b\u306e…<\/p>\n","protected":false},"author":1,"featured_media":208,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[11,8,4],"_links":{"self":[{"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/posts\/207"}],"collection":[{"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/comments?post=207"}],"version-history":[{"count":3,"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/posts\/207\/revisions"}],"predecessor-version":[{"id":249,"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/posts\/207\/revisions\/249"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/media\/208"}],"wp:attachment":[{"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/media?parent=207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/categories?post=207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.hgrs.me\/wp-json\/wp\/v2\/tags?post=207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}