{"id":2888,"date":"2014-08-25T01:24:28","date_gmt":"2014-08-24T16:24:28","guid":{"rendered":"http:\/\/apr20.net\/?p=2888"},"modified":"2014-08-25T01:24:28","modified_gmt":"2014-08-24T16:24:28","slug":"wordpress%e3%81%ae%e6%8a%9c%e7%b2%8b%e8%a1%a8%e7%a4%ba%e3%81%ae%e8%a8%ad%e5%ae%9a","status":"publish","type":"post","link":"https:\/\/apr20.net\/?p=2888","title":{"rendered":"WordPress\u306e\u629c\u7c8b\u8868\u793a\u306e\u8a2d\u5b9a"},"content":{"rendered":"<p>WordPress\u306e\u629c\u7c8b\u8868\u793a(excerpt)\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u52d5\u4f5c\u3055\u305b\u305f\u304b\u3063\u305f\u306e\u3067\u3001\u81ea\u4f5c\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<ol>\n<li>\u629c\u7c8b\u304c\u3042\u308c\u3070\u629c\u7c8b\u8868\u793a<\/li>\n<li>more\u30bf\u30b0\u304c\u3042\u308c\u3070\u3001\u305d\u308c\u306b\u5f93\u3046<\/li>\n<li>\u6307\u5b9a\u6587\u5b57\u6570\u3088\u308a\u672c\u6587\u6587\u5b57\u6570\u304c\u5c11\u306a\u3051\u308c\u3070\u3001\u305d\u306e\u307e\u307e\u8868\u793a<\/li>\n<li>\u6307\u5b9a\u6587\u5b57\u6570\u3088\u308a\u672c\u6587\u6587\u5b57\u6570\u304c\u591a\u3051\u308c\u3070\u629c\u7c8b\u8868\u793a<\/li>\n<\/ol>\n<h2>\u30b3\u30fc\u30c9<\/h2>\n<p>functions.php\u306b\u30b3\u30d4\u30da\u3002<\/p>\n<p>[php]&lt;?php<br \/>\n\/\/WordPress\u629c\u7c8b\u8868\u793a\u306e\u5909\u66f4<br \/>\n\/****<br \/>\n1.\u629c\u7c8b\u304c\u3042\u308c\u3070\u629c\u7c8b\u8868\u793a<br \/>\n2.more\u30bf\u30b0\u304c\u3042\u308c\u3070\u3001\u305d\u308c\u306b\u5f93\u3046<br \/>\n3.$length\u3088\u308a\u6587\u5b57\u304c\u5c11\u306a\u3051\u308c\u3070\u3001\u305d\u306e\u307e\u307e\u8868\u793a<br \/>\n4.$length\u3088\u308a\u6587\u5b57\u304c\u591a\u3051\u308c\u3070\u629c\u7c8b\u8868\u793a<br \/>\n****\/<br \/>\nfunction set_excerpt( $length=200 ){<br \/>\n\tglobal $post;<br \/>\n\t\/\/\u629c\u7c8b\u304c\u5165\u529b\u3055\u308c\u3066\u3044\u308c\u3070\u3001\u629c\u7c8b\u8868\u793a\uff08$length\u7121\u52b9\uff09<br \/>\n\tif(has_excerpt()) {<br \/>\n\t\t$content = strip_tags(get_the_excerpt());<br \/>\n\t\t$content = $content . &#8216;\u2026&#8217;.'&lt;div class=&quot;more&quot;&gt;&lt;a href=&quot;&#8217;.get_permalink().&#8217;&quot; class=&quot;btn btn-default btn-md&quot;&gt;&lt;span class=&quot;glyphicon glyphicon-ok&quot;&gt;&lt;\/span&gt; \u3053\u306e\u8a18\u4e8b\u306e\u7d9a\u304d\u3092\u8aad\u3080&lt;\/a&gt;&lt;\/div&gt;&#8217;;<br \/>\n\t\/\/more\u30bf\u30b0\u304c\u3042\u308b\u5834\u5408<br \/>\n\t\/\/}elseif(preg_match(&#8216;\/&lt;!&#8211;more(.*?)?&#8211;&gt;\/u&#8217;, $post-&gt;post_content, $matches)){<br \/>\n\t}elseif(strpos($post-&gt;post_content,'&lt;!&#8211;more&#8217;)){<br \/>\n\t\tglobal $more; $more = 0;<br \/>\n\t\t$content = strip_tags(get_the_content(&#8221;));<br \/>\n\t\t$content = $content . &#8216;\u2026&#8217;.'&lt;div class=&quot;more&quot;&gt;&lt;a href=&quot;&#8217;.get_permalink().&#8217;&quot; class=&quot;btn btn-default btn-md&quot;&gt;&lt;span class=&quot;glyphicon glyphicon-ok&quot;&gt;&lt;\/span&gt; \u3053\u306e\u8a18\u4e8b\u306e\u7d9a\u304d\u3092\u8aad\u3080&lt;\/a&gt;&lt;\/div&gt;&#8217;;<br \/>\n\t\/\/\u672c\u6587\u306e\u6587\u5b57\u6570\u304c$length\u3088\u308a\u5c11\u306a\u3044\u5834\u5408\u306f\u5168\u6587\u8868\u793a<br \/>\n\t}elseif(mb_strlen( $post -&gt; post_content) &lt;= $length){<br \/>\n\t\t\t$content = strip_tags(get_the_content());<br \/>\n\t}else{<br \/>\n\t\t $content = mb_substr( strip_tags( $post -&gt; post_content ), 0, $length );<br \/>\n\t\t $content = $content . &#8216;\u2026&#8217;.'&lt;div class=&quot;more&quot;&gt;&lt;a href=&quot;&#8217;.get_permalink().&#8217;&quot; class=&quot;btn btn-default btn-md&quot;&gt;&lt;span class=&quot;glyphicon glyphicon-ok&quot;&gt;&lt;\/span&gt; \u3053\u306e\u8a18\u4e8b\u306e\u7d9a\u304d\u3092\u8aad\u3080&lt;\/a&gt;&lt;\/div&gt;&#8217;;<br \/>\n\t}<br \/>\n\t\t return $content;<br \/>\n}<\/p>\n<p>?&gt;[\/php]<\/p>\n<h2>\u4f7f\u7528\u65b9\u6cd5<\/h2>\n<p>\u30c6\u30fc\u30de\u30d5\u30a1\u30a4\u30eb\u306e\u672c\u6587\u306e\u629c\u7c8b\u3092\u8868\u793a\u3055\u305b\u305f\u3044\u306b<code>set_excerpt();<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress\u306e\u629c\u7c8b\u8868\u793a(excerpt)\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u52d5\u4f5c\u3055\u305b\u305f\u304b\u3063\u305f\u306e\u3067&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,2,5],"tags":[],"class_list":["post-2888","post","type-post","status-publish","format-standard","hentry","category-php","category-web","category-wordpress-web-category"],"_links":{"self":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts\/2888","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2888"}],"version-history":[{"count":0,"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts\/2888\/revisions"}],"wp:attachment":[{"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2888"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2888"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2888"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}