{"id":117947,"date":"2009-05-24T19:02:31","date_gmt":"2009-05-24T10:02:31","guid":{"rendered":"https:\/\/ja.wordpress.org\/support\/2009\/05\/24\/%e6%a4%9c%e7%b4%a2%e7%b5%90%e6%9e%9c%e3%82%92google%e3%81%ae%e3%82%88%e3%81%86%e3%81%ab%e8%a1%a8%e7%a4%ba%e3%81%97%e3%81%9f%e3%81%84%e3%80%82\/"},"modified":"2009-05-24T19:02:31","modified_gmt":"2009-05-24T10:02:31","slug":"%e6%a4%9c%e7%b4%a2%e7%b5%90%e6%9e%9c%e3%82%92google%e3%81%ae%e3%82%88%e3%81%86%e3%81%ab%e8%a1%a8%e7%a4%ba%e3%81%97%e3%81%9f%e3%81%84%e3%80%82","status":"closed","type":"topic","link":"https:\/\/ja.wordpress.org\/support\/topic\/%e6%a4%9c%e7%b4%a2%e7%b5%90%e6%9e%9c%e3%82%92google%e3%81%ae%e3%82%88%e3%81%86%e3%81%ab%e8%a1%a8%e7%a4%ba%e3%81%97%e3%81%9f%e3%81%84%e3%80%82\/","title":{"rendered":"\u691c\u7d22\u7d50\u679c\u3092Google\u306e\u3088\u3046\u306b\u8868\u793a\u3057\u305f\u3044\u3002"},"content":{"rendered":"<p>\u691c\u7d22\u30d5\u30a9\u30fc\u30e0\u3067\u306e\u8a18\u4e8b\u691c\u7d22\u306e\u7d50\u679c\u3092Google\u306e\u691c\u7d22\u7d50\u679c\u306e\u3088\u3046\u306b<br \/>\n\u8868\u793a\u3057\u305f\u3044\u306e\u3067\u3059\u304c\u3001\u305d\u306e\u305f\u3081\u306e\u4fbf\u5229\u306a\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30bf\u30b0\u307e\u305f\u306f<br \/>\n\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u6559\u3048\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u5177\u4f53\u7684\u306b\u306f<\/p>\n<ul>\n<li>\u30d2\u30c3\u30c8\u3057\u305f\u8a18\u4e8b\u306e\u30bf\u30a4\u30c8\u30eb\u3001\u672c\u6587\u3092\u8868\u793a\u3057\u305f\u3044\u3002<\/li>\n<li>\u30d2\u30c3\u30c8\u3057\u305f\u8a18\u4e8b\u304b\u3089\u3001\u6700\u521d\u306b\u5f53\u3066\u306f\u307e\u3063\u305f\u691c\u7d22\u8a9e\u8fd1\u8fba\u306e<br \/>\n\uff12\uff10\uff10\u6587\u5b57\u7a0b\u5ea6\u3092\u629c\u304d\u51fa\u3057\u305f\u3044\u3002<\/li>\n<li>\u691c\u7d22\u8a9e\u3068\u540c\u3058\u6587\u5b57\u306f\u592a\u5b57\u3067\u8868\u793a\u3057\u305f\u3044\u3002<\/li>\n<\/ul>\n<p>WordPress\u306e\u5185\u90e8\u95a2\u6570\u3092\u5229\u7528\u3057\u3001\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3063\u3066\u3001<br \/>\n\u300e\u3068\u308a\u3042\u3048\u305a\u52d5\u304f\u300f\u3082\u306e\u306f\u4f5c\u308a\u307e\u3057\u305f\u3002\u2193<br \/>\n\u2026\u3057\u304b\u3057\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30bf\u30b0\u7b49\u3067\u7c21\u5358\u306b\u3001\u5b89\u5168\u78ba\u5b9f\u306b\u8868\u793a\u3067\u304d\u308b\u306a\u3089<br \/>\n\u305d\u306e\u65b9\u6cd5\u3092\u63a1\u308a\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p><code><br \/>\n\/&#47;*********************************************<br \/>\nif (have_posts()):<br \/>\nwhile (have_posts()):<br \/>\n  the_post();<\/p>\n<p>  \/\/WordPress\u30eb\u30fc\u30d7\u4e2d\u3067\u3001\u30bf\u30a4\u30c8\u30eb\u3068\u672c\u6587\u3092\u53d6\u5f97<br \/>\n  $title   = strip_tags($post-&gt;post_title);<br \/>\n  $content = strip_tags($post-&gt;post_content);<\/p>\n<p>  \/\/\u691c\u7d22\u8a9e\u3092\u5206\u5272<br \/>\n  $arr_s = mb_split(&quot; |\u3000&quot;,$s);<\/p>\n<p>  \/\/-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;<br \/>\n  \/\/\u672c\u6587\u306e\u6574\u5f62<br \/>\n  \/\/\u691c\u7d22\u8a9e\u306e\u3046\u3061\u3001\u3069\u308c\u304b\u3072\u3068\u3064\u3067\u3082\u30d2\u30c3\u30c8\u3057\u305f\u304b\uff1f<br \/>\n  $pos = -1;<br \/>\n  foreach($arr_s as $s_word){<br \/>\n    $pos = mb_strpos($content, $s_word);<br \/>\n    if($pos &gt;= 0){<br \/>\n      break;<br \/>\n    }<br \/>\n  }<br \/>\n  if($pos &lt; 0){<br \/>\n    $pos = 0;<br \/>\n  }<\/p>\n<p>  \/\/\u898b\u3064\u304b\u3063\u305f\u5834\u6240\u304b\u3089100\u6587\u5b57\u3092\u62bd\u51fa<br \/>\n  $content01 = mb_substr($content, $pos, 100);<\/p>\n<p>  \/\/\u898b\u3064\u304b\u3063\u305f\u5834\u6240\u624b\u524d\u304b\u3089100\u6587\u5b57\u62bd\u51fa<br \/>\n  \/\/(\u6587\u982d\u3092\u304d\u308c\u3044\u306b\u6574\u3048\u308b)<br \/>\n  $distant = 200 - mb_strlen($content01);<br \/>\n  $pos2 = $pos - $distant;<br \/>\n  if($pos2 &lt; 0){<br \/>\n    $distant += $pos2;<br \/>\n    $pos2 = 0;<br \/>\n  }<br \/>\n  $content02 = mb_substr($content, $pos2, $distant);<br \/>\n  $arr_con2 = mb_split(&quot; |\u3000|\\.|\u3002|\\,|\u3001&quot;, $content02, 2);<br \/>\n  $i = count($arr_con2) - 1;<br \/>\n  $content02 = $arr_con2[$i];<\/p>\n<p>  \/\/\u898b\u3064\u304b\u3063\u305f\u5834\u6240\u8fd1\u8fba\u306e\u6587\u7ae0\u3068\u3057\u3066\u524d\u5f8c\u3092\u5408\u4f53\u3055\u305b\u308b<br \/>\n  $content = $content02 . $content01;<br \/>\n  \/\/-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;-&#45;<\/p>\n<p>  \/\/\u30d2\u30c3\u30c8\u6587\u5b57\u5217\u3092\u592a\u5b57\u306b<br \/>\n  foreach($arr_s as $s_word){<br \/>\n    $title   = preg_replace(&#39;\/&#39;.$s_word.&#39;\/i&#39;, &quot;<strong>&quot;.$s_word.&quot;<\/strong>&quot;, $title);<br \/>\n    $content = preg_replace(&#39;\/&#39;.$s_word.&#39;\/i&#39;, &quot;<strong>&quot;.$s_word.&quot;<\/strong>&quot;, $content);<br \/>\n  }<\/p>\n<p>  \/\/\u753b\u9762\u306b\u8868\u793a<br \/>\n  echo &quot;&lt;div&gt;<a href=\"\\&quot;&quot;.get_permalink($post-\">ID).&quot;\\&quot;&gt;$title<\/a>&lt;\/div&gt;\\n&quot;;<br \/>\n  echo &quot;&lt;div&gt;$content ...&lt;\/div&gt;\\n&quot;;<\/p>\n<p>endwhile;<br \/>\nendif;<br \/>\n<\/code><\/p>\n","protected":false},"template":"","class_list":["post-117947","topic","type-topic","status-closed","hentry","topic-tag-search"],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/ja.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/117947","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ja.wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/ja.wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/ja.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/117947\/revisions"}],"wp:attachment":[{"href":"https:\/\/ja.wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=117947"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}