{"id":268,"date":"2010-11-24T15:16:22","date_gmt":"2010-11-24T06:16:22","guid":{"rendered":"http:\/\/www.myu-zin.com\/webridge\/?p=268"},"modified":"2010-11-24T15:43:59","modified_gmt":"2010-11-24T06:43:59","slug":"wordpress%e3%81%ab%e3%81%99%e3%81%b9%e3%81%a6%e3%81%ae%e7%94%bb%e5%83%8f%e4%b8%80%e8%a6%a7%e3%83%9a%e3%83%bc%e3%82%b8%e3%82%92%e8%a8%ad%e7%bd%ae%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/www.myu-zin.com\/webridge\/archives\/268.html","title":{"rendered":"WordPress\u306b\u3059\u3079\u3066\u306e\u753b\u50cf\u4e00\u89a7\u30da\u30fc\u30b8\u3092\u8a2d\u7f6e\u3059\u308b"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-271\" title=\"aaa\" src=\"http:\/\/www.myu-zin.com\/webridge\/wp-content\/uploads\/aaa-150x150.jpg\" alt=\"\" width=\"150\" height=\"150\" srcset=\"https:\/\/www.myu-zin.com\/webridge\/wp-content\/uploads\/aaa-150x150.jpg 150w, https:\/\/www.myu-zin.com\/webridge\/wp-content\/uploads\/aaa-300x300.jpg 300w, https:\/\/www.myu-zin.com\/webridge\/wp-content\/uploads\/aaa.jpg 400w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/p>\n<p>\u5404\u6295\u7a3f\u753b\u9762\u306b\u306f\u3001\u3055\u307e\u3056\u307e\u306a\u30e1\u30c7\u30a3\u30a2\u3092\u4e00\u7dd2\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u5404\u8a18\u4e8b\u3054\u3068\u306b\u898b\u308b\u306b\u306f\u5341\u5206\u3067\u3059\u304c\u3001<\/p>\n<p><span style=\"color: #008000; font-size: 16px;\"><strong>\u300c\u3048\uff5e\u3044\u3063\uff01\u307e\u3068\u3081\u3066\u307f\u305f\u3044\u308f\u3041\u30fc\u300d<\/strong><\/span><\/p>\n<p>\u3063\u3068\u3044\u3046\u3068\u304d\u306b\u4fbf\u5229\u306a\u753b\u50cf\u4e00\u89a7\u30da\u30fc\u30b8\u3092\u8a2d\u7f6e\u3057\u3066\u307f\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u65b0\u898f\u306b\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u300cimages.php\u300d\u3068\u3057\u307e\u3059\u3002<\/p>\n<p>\u300cimages.php\u300d\u306e\u4e2d\u306b\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u3092\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u30c8\u30c3\u30d7\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u4fdd\u5b58\u3057\u3001\u7ba1\u7406\u753b\u9762\u304b\u3089\u300c\u30da\u30fc\u30b8\u65b0\u898f\u8ffd\u52a0\u300d\u21d2\u300c\u4f5c\u6210\u3057\u305f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u9078\u629e\u300d\u3067\u5185\u5bb9\u3092\u7a7a\u306e\u307e\u307e\u66f4\u65b0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3053\u308c\u307e\u3067\u63b2\u8f09\u3055\u308c\u305f\u3059\u3079\u3066\u306e\u753b\u50cf\u304c\u4e00\u89a7\u8868\u793a\u3055\u308c\u308b\u306f\u305a\u3067\u3059\uff01<br \/>\n<a href=\"http:\/\/www.myu-zin.com\/webridge\/listimage\" target=\"_blank\">\u753b\u50cf\u4e00\u89a7\u306e\u30da\u30fc\u30b8Sample <\/a><\/p>\n<p><!--more--><\/p>\n<pre class=\"brush: php; title: \u30bd\u30fc\u30b9\u30b3\u30fc\u30c9; notranslate\" title=\"\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\">\r\n&lt;?php\r\n\/*\r\nTemplate Name: \u753b\u50cf\u4e00\u89a7\r\n*\/\r\n?&gt;\r\n&lt;?php\r\n\/\/ \u5909\u6570\u306e\u521d\u671f\u5316\r\n$per_page =20;\r\n$per_row = 4;\r\n$max_width = 160;\r\n$max_height =160;\r\n\/*\r\n$per_page = 10;\r\n$per_row = 2;\r\n$max_width = 200;\r\n$max_height = 150;\r\n*\/\r\n\/\/ \u753b\u50cf\u306e\u6570\u3092\u5f97\u308b\r\n$sql = &lt;&lt;&lt; HERE\r\nSELECT COUNT(a.ID) FROM $wpdb-&gt;posts a, $wpdb-&gt;posts p\r\nWHERE a.post_parent = p.ID\r\nAND a.post_mime_type LIKE 'image\/%'\r\nAND a.post_type = 'attachment'\r\nAND p.post_status = 'publish'\r\nHERE;\r\n$count = $wpdb-&gt;get_var($sql);\r\n\/\/ \u753b\u50cf\u306e\u6570\u304b\u3089\u5168\u30da\u30fc\u30b8\u6570\u3092\u6c42\u3081\u308b\r\n$page_counts = ceil($count \/ $per_page);\r\n\/\/ URL\u304b\u3089\u30da\u30fc\u30b8\u756a\u53f7\u3092\u5f97\u308b\r\n$page_no = intval($wp_query-&gt;get('paged'));\r\nif ($page_no &lt; 1) {\r\n\t$page_no = 1;\r\n}\r\nelse if ($page_no &gt; $page_counts) {\r\n\t$page_no = $page_counts;\r\n}\r\n\/\/ \u30aa\u30d5\u30bb\u30c3\u30c8\u3092\u6c42\u3081\u308b\r\n$offset = ($page_no - 1) * $per_page;\r\n\/\/ \u30da\u30fc\u30b8\u5185\u306e\u5148\u982d\u3068\u6700\u5f8c\u306e\u753b\u50cf\u306e\u756a\u53f7\u3092\u6c42\u3081\u308b\r\n$page_start = ($page_no - 1) * $per_page + 1;\r\n$page_end = $page_no * $per_page;\r\nif ($page_end &gt; $count) {\r\n\t$page_end = $count;\r\n}\r\n\/\/ \u753b\u50cf\u3092\u8aad\u307f\u8fbc\u3080\r\n$sql = &lt;&lt;&lt; HERE\r\nSELECT a.* FROM $wpdb-&gt;posts a, $wpdb-&gt;posts p\r\nWHERE a.post_parent = p.ID\r\nAND a.post_mime_type LIKE 'image\/%'\r\nAND a.post_type = 'attachment'\r\nAND p.post_status = 'publish'\r\nORDER BY a.post_date DESC\r\nLIMIT $offset, $per_page\r\nHERE;\r\n$attachments = $wpdb-&gt;get_results($sql);\r\n?&gt;\r\n\r\n&lt;?php get_header(); ?&gt;\r\n\r\n\t&lt;div id=&quot;listimage&quot; class=&quot;clearfix&quot;&gt;\r\n\r\n\t\t&lt;div id=&quot;contentimage&quot; class=&quot;maincontent&quot;&gt;\r\n\r\n\t\t\t&lt;h1&gt;\u753b\u50cf\u306e\u4e00\u89a7(&lt;?php echo $count; ?&gt;\u4ef6\u4e2d&lt;?php echo $page_start; ?&gt;\uff5e&lt;?php echo $page_end; ?&gt;\u4ef6\u76ee)&lt;\/h1&gt;\r\n\r\n\t\t\t&lt;?php\r\n\t\t\t$ctr = 0;\r\n\t\t\t\/\/ \u753b\u50cf\u3092\u9806\u306b\u51fa\u529b\u3059\u308b\r\n\t\t\tforeach ($attachments as $attachment) :\r\n\t\t\t\t\/\/ \u753b\u50cf\u306e\u8cbc\u308a\u4ed8\u3051\u5148\u6295\u7a3f\u306e\u30bf\u30a4\u30c8\u30eb\u3068\u30a2\u30c9\u30ec\u30b9\u3092\u5f97\u308b\r\n\t\t\t\t$post = get_post($attachment-&gt;post_parent);\r\n\t\t\t\tsetup_postdata($post);\r\n\t\t\t\t$attached_title = get_the_title($post-&gt;ID);\r\n\t\t\t\t$attached_url = get_permalink($post-&gt;ID);\r\n\r\n\t\t\t\t\/\/ \u753b\u50cf\u306e\u30a2\u30c9\u30ec\u30b9\uff0f\u6982\u8981\uff0f\u30bf\u30a4\u30c8\u30eb\u3092\u5f97\u308b\r\n\t\t\t\t$post = $attachment;\r\n\t\t\t\tsetup_postdata($post);\r\n                                $url = wp_get_attachment_url($post-&gt;ID);\r\n                                $alt = $post-&gt;post_content;\r\n\t\t\t\t$title = $post-&gt;post_excerpt;\r\n\r\n\t\t\t\t\/\/ \u753b\u50cf\u306e\u5e45\u3068\u9ad8\u3055\u3092\u6c42\u3081\u308b\r\n\t\t\t\t$at_data = wp_get_attachment_metadata($post-&gt;ID);\r\n\t\t\t\t$width = $at_data&#x5B;'width'];\r\n\t\t\t\t$height = $at_data&#x5B;'height'];\r\n\t\t\t\tif (!$width || !$height) {\r\n\t\t\t\t\t$width = $max_width;\r\n\t\t\t\t\t$height = $max_height;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t\/\/ \u753b\u50cf\u306e\u7e26\u6a2a\u6bd4\u3092\u7dad\u6301\u3057\u305f\u307e\u307e\u3001\r\n\t\t\t\t\/\/ \u5e45\u304c$max_width\uff0f\u9ad8\u3055\u304c$max_height\u306b\u53ce\u307e\u308b\u3088\u3046\u306b\r\n\t\t\t\t\/\/ \u30b5\u30a4\u30ba\u3092\u8a08\u7b97\u3057\u306a\u304a\u3059\r\n\t\t\t\tif ($width &gt; $max_width || $height &gt; $max_height) {\r\n\t\t\t\t\t\/\/ \u6a2a\u9577\u306e\u753b\u50cf\u306e\u5834\u5408\r\n\t\t\t\t\tif ($width \/ $height &gt;= $max_width \/ $max_height) {\r\n\t\t\t\t\t\t$rate = $max_width \/ $width;\r\n\t\t\t\t\t\t$width = $max_width;\r\n\t\t\t\t\t\t$height = $height * $rate;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\/\/ \u7e26\u9577\u306e\u753b\u50cf\u306e\u5834\u5408\r\n\t\t\t\t\telse {\r\n\t\t\t\t\t\t$rate = $max_height \/ $height;\r\n\t\t\t\t\t\t$width = $width * $rate;\r\n\t\t\t\t\t\t$height = $max_height;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t\/\/ \u884c\u306e\u5148\u982d\uff0f\u6700\u5f8c\u304b\u3069\u3046\u304b\u3092\u3001\u5909\u6570$row_first\uff0f$row_end\u306b\u4ee3\u5165\u3059\u308b\r\n\t\t\t\t$row_first = ($ctr % $per_row == 0);\r\n\t\t\t\t$row_end = ($ctr % $per_row == $per_row - 1);\r\n\t\t\t?&gt;\r\n\r\n&lt;!-- \u4e00\u679a\u5206 --&gt;\r\n&lt;div class=&quot;imagebox&quot;&gt;\r\n&lt;p&gt;&lt;a href=&quot;&lt;?php echo $url; ?&gt;&quot; class=&quot;thickbox&quot;&gt;\r\n&lt;img src=&quot;&lt;?php echo $url; ?&gt;&quot; width=&quot;&lt;?php echo $width; ?&gt;&quot; height=&quot;&lt;?php echo $height; ?&gt;&quot; alt=&quot;&lt;?php echo $alt ?&gt;&quot; title=&quot;&lt;?php echo $title ?&gt;&quot; \/&gt;\r\n&lt;\/a&gt;&lt;\/p&gt;\r\n\r\n&lt;span&gt;&lt;a href=&quot;&lt;?php echo $attached_url; ?&gt;&quot; title=&quot;&lt;?php echo $attached_title; ?&gt;\u306e\u8a18\u4e8b\u306b\u30b8\u30e3\u30f3\u30d7&quot;&gt;&lt;?php echo $attached_title; ?&gt;&lt;\/a&gt;&lt;\/span&gt;\r\n&lt;\/div&gt;\r\n\r\n\t\t\t&lt;?php endforeach; ?&gt;\r\n\t\t\t&lt;?php if ($ctr % $per_row != 0) : while ($ctr % $per_row != 0) : ?&gt;\r\n\r\n&lt;div class=&quot;imagebox&quot;&gt;&amp;nbsp;&lt;\/div&gt;\r\n\r\n\t\t\t&lt;?php $ctr++; endwhile; ?&gt;\r\n\r\n\t\t\t&lt;?php endif; ?&gt;\r\n\r\n&lt;!-- \u3053\u3053\u307e\u3067\u753b\u50cf --&gt;\r\n&lt;div style=&quot;clear:both;&quot;&gt;&lt;\/div&gt;\r\n\r\n\t\t\t&lt;?php if ($page_counts &gt; 1) : ?&gt;\r\n\t\t\t&lt;p class=&quot;page-list&quot;&gt;\r\n\t\t\t&lt;?php if ($page_no != 1) : ?&gt;\r\n\t\t\t\t&lt;span class=&quot;mark&quot;&gt;&lt;a href=&quot;&lt;?php echo get_pagenum_link(1); ?&gt;&quot;&gt;\u6700\u521d\u306e\u30da\u30fc\u30b8&lt;\/a&gt;&lt;\/span&gt;\r\n\t\t\t\t&lt;span class=&quot;mark&quot;&gt;&lt;a href=&quot;&lt;?php echo get_pagenum_link($page_no - 1); ?&gt;&quot;&gt;\u524d\u306e\u30da\u30fc\u30b8&lt;\/a&gt;&lt;\/span&gt;\r\n\t\t\t&lt;?php endif; ?&gt;\r\n\t\t\t&lt;?php for ($i = 1; $i &lt;= $page_counts; $i++) : ?&gt;\r\n\t\t\t\t&lt;?php if ($i == $page_no) : ?&gt;\r\n\t\t\t\t&lt;span class=&quot;namber now&quot;&gt;&lt;?php echo $i; ?&gt;&lt;\/span&gt;\r\n\t\t\t\t&lt;?php else : ?&gt;\r\n\t\t\t\t&lt;span class=&quot;namber&quot;&gt;&lt;a href=&quot;&lt;?php echo get_pagenum_link($i); ?&gt;&quot;&gt;&lt;?php echo $i; ?&gt;&lt;\/a&gt;&lt;\/span&gt;\r\n\t\t\t&lt;?php endif; ?&gt;\r\n\t\t\t&lt;?php endfor; ?&gt;\r\n\t\t\t&lt;?php if ($page_no != $page_counts) : ?&gt;\r\n\t\t\t\t&lt;span class=&quot;mark&quot;&gt;&lt;a href=&quot;&lt;?php echo get_pagenum_link($page_no + 1); ?&gt;&quot;&gt;\u6b21\u306e\u30da\u30fc\u30b8&lt;\/a&gt;&lt;\/span&gt;\r\n\t\t\t\t&lt;span class=&quot;mark&quot;&gt;&lt;a href=&quot;&lt;?php echo get_pagenum_link($page_counts); ?&gt;&quot;&gt;\u6700\u5f8c\u306e\u30da\u30fc\u30b8&lt;\/a&gt;&lt;\/span&gt;\r\n\t\t\t&lt;?php endif; ?&gt;\r\n\t\t\t&lt;\/p&gt;\r\n\t\t\t&lt;?php endif; ?&gt;\r\n\r\n&lt;\/div&gt;\r\n\r\n&lt;?php get_footer(); ?&gt;\r\n<\/pre>\n<p>\n<a href=\"http:\/\/www.amazon.co.jp\/dp\/488337730X?tag=maquo-22&amp;camp=1027&amp;creative=7407&amp;linkCode=as4&amp;creativeASIN=488337730X&amp;adid=0HV2V2ZBSFVT1P6D0Z4F&amp;\" target=\"_blank\"><img decoding=\"async\" src=\"http:\/\/ecx.images-amazon.com\/images\/I\/51wTz7ZVbmL._SY180_.jpg\" style=\"float:right;\"><\/a> <\/p>\n<p>\u53f3\u306e\u672c\u3092\u53c2\u8003\u306b\u3057\u307e\u3057\u305f\u3002\u5b9f\u969b\u306b\u306f\u3082\u3063\u3068\u8c4a\u5bcc\u306a\u30b5\u30f3\u30d7\u30eb\u3068\u89e3\u8aac\u3067\u3001\u78ba\u5b9f\u306b\u899a\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u306f\u305a\u3002\u672c\u306b\u3082\u5408\u3046\u4eba\u3068\u5408\u308f\u306a\u3044\u4eba\u304c\u3044\u307e\u3059\u304c\u3001\u308f\u304b\u308a\u3084\u3059\u3044\u672c\u306e\uff11\u518a\u3067\u3059\u3002<br \/>\n<a href=\"http:\/\/www.amazon.co.jp\/dp\/488337730X?tag=maquo-22&amp;camp=1027&amp;creative=7407&amp;linkCode=as4&amp;creativeASIN=488337730X&amp;adid=0HV2V2ZBSFVT1P6D0Z4F&amp;\" target=\"_blank\">PHP\u306b\u3088\u308bWordPress\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u30d6\u30c3\u30af<\/a><br \/>\u85e4\u672c \u58f1<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5404\u6295\u7a3f\u753b\u9762\u306b\u306f\u3001\u3055\u307e\u3056\u307e\u306a\u30e1\u30c7\u30a3\u30a2\u3092\u4e00\u7dd2\u306b\u30a2\u30c3\u30d7\u30ed\u30fc&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-268","post","type-post","status-publish","format-standard","hentry","category-wordpress"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.myu-zin.com\/webridge\/wp-json\/wp\/v2\/posts\/268","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.myu-zin.com\/webridge\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.myu-zin.com\/webridge\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.myu-zin.com\/webridge\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.myu-zin.com\/webridge\/wp-json\/wp\/v2\/comments?post=268"}],"version-history":[{"count":13,"href":"https:\/\/www.myu-zin.com\/webridge\/wp-json\/wp\/v2\/posts\/268\/revisions"}],"predecessor-version":[{"id":283,"href":"https:\/\/www.myu-zin.com\/webridge\/wp-json\/wp\/v2\/posts\/268\/revisions\/283"}],"wp:attachment":[{"href":"https:\/\/www.myu-zin.com\/webridge\/wp-json\/wp\/v2\/media?parent=268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.myu-zin.com\/webridge\/wp-json\/wp\/v2\/categories?post=268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.myu-zin.com\/webridge\/wp-json\/wp\/v2\/tags?post=268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}