{"id":453,"date":"2017-08-10T06:35:54","date_gmt":"2017-08-09T21:35:54","guid":{"rendered":"https:\/\/blog.srytk.com\/aquei\/?p=453"},"modified":"2017-08-10T06:35:54","modified_gmt":"2017-08-09T21:35:54","slug":"wordpress%e3%81%aeget_the_excerpt%e9%96%a2%e6%95%b0%e3%81%abpost%e3%82%aa%e3%83%96%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%82%92%e6%b8%a1%e3%81%99%e3%81%ae%e3%81%af%e6%b3%a8%e6%84%8f%e6%b7%b1%e3%81%8f","status":"publish","type":"post","link":"https:\/\/blog.srytk.com\/aquei\/453.html","title":{"rendered":"WordPress\u306eget_the_excerpt\u95a2\u6570\u306bpost\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u6e21\u3059\u306e\u306f\u6ce8\u610f\u6df1\u304f\u306d"},"content":{"rendered":"<p>WordPress\u306b\u306f\u6295\u7a3f\u306e\u629c\u7c8b\u30c6\u30ad\u30b9\u30c8\u3092\u5f97\u308b\u305f\u3081\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30bf\u30b0\uff08\u95a2\u6570\uff09<a href=\"https:\/\/wpdocs.osdn.jp\/%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%82%BF%E3%82%B0\/get_the_excerpt\"><code>get_the_excerpt<\/code><\/a>\u304c\u3042\u308b\u3002WordPress Codex\u65e5\u672c\u8a9e\u7248\u306e\u60c5\u5831\u306f\u66f4\u65b0\u3055\u308c\u3066\u3044\u306a\u3044\u3088\u3046\u3060\u304c\u3001<a href=\"https:\/\/codex.wordpress.org\/Function_Reference\/get_the_excerpt\">\u82f1\u8a9e\u7248Codex\u306b\u3088\u308c\u3070<\/a>\u3001\u30eb\u30fc\u30d7\u5185\u5916\u3092\u554f\u308f\u305a<code>get_the_excerpt<\/code>\u306b\u4efb\u610f\u306e<a href=\"https:\/\/wpdocs.osdn.jp\/%E3%82%AF%E3%83%A9%E3%82%B9%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9\/WP_Post\">post\u30aa\u30d6\u30b8\u30a7\u30af\u30c8(WP_Post\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9<\/a>)\u304b\u6295\u7a3fID\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6e21\u305b\u3070\u3001\u305d\u306e\u6295\u7a3f\u306e\u629c\u7c8b\u6587\u304c\u5f97\u3089\u308c\u308b\uff08\u3053\u3068\u306b\u306a\u3063\u3066\u3044\u308b\uff09\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><!--more--><\/p>\n<p>\u305f\u3060\u3001<code>get_the_excerpt<\/code>\u306b\u306f\u30d0\u30b0\u304c\u3042\u3063\u3066\u3001\u73fe\u72b6\u3001<a href=\"https:\/\/core.trac.wordpress.org\/ticket\/36934\">post\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f34\u3063\u3066\u547c\u3073\u51fa\u3059\u3068\u610f\u56f3\u3057\u306a\u3044\u7d50\u679c\u306b\u306a\u308b<\/a>\u3053\u3068\u304c\u3042\u308b\u3002<\/p>\n<blockquote><p>There are a few things wrong:<\/p>\n<p>1) The behaviour is inconsistent depending on usage.<\/p>\n<p>If you call get_the_excerpt() within the loop and if the post has no excerpt, then the post content will be stripped and truncated.<\/p>\n<p>If you call it with the $post parameter and the post has no excerpt then nothing is returned.<\/p>\n<p>Well&#8230;sometimes&#8230;<\/p>\n<p>2) If you are inside a loop &#8211; say you&#8217;re using get_the_excerpt($post) in a shortcode in a post &#8211; then you will actually get back the truncated content of the post from the loop that you are in.<\/p><\/blockquote>\n<p>\u304b\u3044\u3064\u307e\u3080\u3068\u3001\u6295\u7a3f\u306b\u30e6\u30fc\u30b6\u30fc\u304c\u8a2d\u5b9a\u3057\u305f\u629c\u7c8b($post-&gt;post_excerpt)\u304c\u306a\u3044\u5834\u5408\u3001\u4f55\u3082\u30ea\u30bf\u30fc\u30f3\u3055\u308c\u306a\u3044\u3053\u3068\u304c\u3042\u3063\u305f\u308a\u3001\u30eb\u30fc\u30d7\u5185\u3060\u3068\u73fe\u5728\u306e\u30eb\u30fc\u30d7\u306b\u3042\u308b\u6295\u7a3f(<code>global $post<\/code>)\u306e\u629c\u7c8b\u6587\u304c\u30ea\u30bf\u30fc\u30f3\u3055\u308c\u305f\u308a\u3059\u308b\u3002\u5b8c\u5168\u306b\u3076\u3063\u58ca\u308c\u3066\u3044\u308b\u3002<\/p>\n<p>\u3053\u308c\u306f\u3001\u6295\u7a3f\u306b\u30e6\u30fc\u30b6\u304c\u8a2d\u5b9a\u3057\u305f\u629c\u7c8b\u304c\u306a\u304b\u3063\u305f\u5834\u5408\u3001\u672c\u6587\u304b\u3089\u629c\u7c8b\u6587\u3092\u751f\u6210\u3059\u308b\u904e\u7a0b\u3067\u3001\u751f\u6210\u5143\u306e\u672c\u6587\u3068\u3057\u3066<code>get_the_content('')<\/code>\u304c\u5229\u7528\u3055\u308c\u308b\u304b\u3089\u3089\u3057\u3044\u3002\u3064\u307e\u308a\u3001\u201d\u73fe\u5728\u201d\u306e\u6295\u7a3f\u306e\u201d\u672c\u6587\u201d\u304c\u629c\u7c8b\u30bd\u30fc\u30b9\u3068\u3057\u3066\u4f7f\u308f\u308c\u308b\u3002\u3068\u3044\u3046\u3053\u3068\u306f\u3001\u629c\u7c8b\u5206\u3092\u53d6\u5f97\u3059\u308b\u3068\u304d\u306b\u4e00\u6642\u7684\u306bglobal $post\u306b\u76ee\u7684\u306epost\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u8a2d\u5b9a\u3057\u3066\u304a\u3044\u3066\u3001\u53d6\u5f97\u3057\u7d42\u308f\u3063\u305f\u3089$post\u306b\u30aa\u30ea\u30b8\u30ca\u30eb\u306e$post\u3092\u8a2d\u5b9a\u3059\u308c\u3070\u3044\u3044\u306e\u304b\u3082\u3057\u308c\u306a\u3044\u3002\u8a66\u3057\u3066\u306a\u3044\u304c\u3002<\/p>\n<p>get_the_excerpt\u306f\u7d50\u69cb\u3088\u304f\u4f7f\u308f\u308c\u305d\u3046\u306a\u30bf\u30b0\u306b\u3082\u304b\u304b\u308f\u3089\u305a\u3001\u3053\u306e\u3088\u3046\u306a\u30d0\u30b0\u304c\uff11\u5e74\u4ee5\u4e0a\u4fee\u6b63\u3055\u308c\u3066\u306a\u3044\u3068\u3044\u3046\u306e\u306f\u8f9b\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress\u306b\u306f\u6295\u7a3f\u306e\u629c\u7c8b\u30c6\u30ad\u30b9\u30c8\u3092\u5f97\u308b\u305f\u3081\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30bf\u30b0\uff08\u95a2\u6570\uff09get_the_excerpt\u304c\u3042\u308b\u3002WordPress Codex\u65e5\u672c\u8a9e\u7248\u306e\u60c5\u5831\u306f\u66f4\u65b0\u3055\u308c\u3066\u3044\u306a\u3044\u3088\u3046\u3060\u304c\u3001\u82f1\u8a9e\u7248Codex\u306b\u3088\u308c\u3070\u3001\u30eb\u30fc\u30d7\u5185 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"activitypub_content_warning":"","activitypub_content_visibility":"local","activitypub_max_image_attachments":5,"footnotes":""},"categories":[2],"tags":[3],"class_list":["post-453","post","type-post","status-publish","format-standard","hentry","category-tech","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/blog.srytk.com\/aquei\/wp-json\/wp\/v2\/posts\/453","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.srytk.com\/aquei\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.srytk.com\/aquei\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.srytk.com\/aquei\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.srytk.com\/aquei\/wp-json\/wp\/v2\/comments?post=453"}],"version-history":[{"count":3,"href":"https:\/\/blog.srytk.com\/aquei\/wp-json\/wp\/v2\/posts\/453\/revisions"}],"predecessor-version":[{"id":456,"href":"https:\/\/blog.srytk.com\/aquei\/wp-json\/wp\/v2\/posts\/453\/revisions\/456"}],"wp:attachment":[{"href":"https:\/\/blog.srytk.com\/aquei\/wp-json\/wp\/v2\/media?parent=453"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.srytk.com\/aquei\/wp-json\/wp\/v2\/categories?post=453"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.srytk.com\/aquei\/wp-json\/wp\/v2\/tags?post=453"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}