{"id":3297,"date":"2012-03-27T04:05:50","date_gmt":"2012-03-26T19:05:50","guid":{"rendered":"http:\/\/www.webcyou.com\/?p=3297"},"modified":"2012-03-27T04:07:01","modified_gmt":"2012-03-26T19:07:01","slug":"wordpress-%e3%83%ab%e3%83%bc%e3%83%97%e3%81%ae%e5%9f%ba%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/www.webcyou.com\/?p=3297","title":{"rendered":"WordPress \u30eb\u30fc\u30d7\u306e\u57fa\u672c"},"content":{"rendered":"<p>WordPress\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3059\u308b\u969b\u3001\u30ad\u30e2\u3068\u306a\u308b\u306e\u304cWordPress\u306e\u30eb\u30fc\u30d7\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f\u305d\u306eWordPress\u306e\u30eb\u30fc\u30d7\u306b\u95a2\u3057\u3066\u307e\u3068\u3081\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<h4>WordPress\u00a0\u30eb\u30fc\u30d7<\/h4>\n<p>wordpress\u306e\u30eb\u30fc\u30d7\u306e\u57fa\u790e\u306e\u8a18\u8ff0\u3067\u3059\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">&lt;?php if (have_posts()) : ?&gt;\r\n    &lt;?php while (have_posts()) : the_post(); ?&gt; \/\/ \u30eb\u30fc\u30d7\u51e6\u7406\r\n    &lt;?php endwhile; ?&gt;\r\n&lt;?php endif; ?&gt;\r\n<\/pre>\n<p><strong>\u300c\u8a72\u5f53\u3059\u308b\u8a18\u4e8b\u304c\u3042\u308b\u306a\u3089\u3070\u3001\u3042\u308b\u3060\u3051\u30eb\u30fc\u30d7\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u300d<\/strong>\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u306ewordpress\u306e\u30eb\u30fc\u30d7\u306b\u95a2\u3057\u3066\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h4>WordPress\u00a0\u30eb\u30fc\u30d7\u306e\u7a2e\u985e<\/h4>\n<p>WordPress\u306e\u30eb\u30fc\u30d7\u306f<strong>\u30e1\u30a4\u30f3\u30eb\u30fc\u30d7<\/strong>\u3068<strong>\u30b5\u30d6\u30eb\u30fc\u30d7<\/strong>\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u30e1\u30a4\u30f3\u30eb\u30fc\u30d7\u306f\u57fa\u672c\u30011\u30da\u30fc\u30b8\u306b1\u56de\u3057\u304b\u767b\u5834\u3057\u306a\u3044\u30eb\u30fc\u30d7\u306e\u3053\u3068\u3067\u3001\u30b5\u30d6\u30eb\u30fc\u30d7\u3068\u306f\u8907\u6570\u306e\u30eb\u30fc\u30d7\u3092\u4f5c\u6210\u3059\u308b\u4e8b\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n<p>\u30e1\u30a4\u30f3\u30eb\u30fc\u30d7\u3092\u4f5c\u6210\uff08\u30aa\u30ea\u30b8\u30ca\u30eb\u306e\u30eb\u30fc\u30d7\u3092\u5143\u306b\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\uff09\u3059\u308b\u969b\u3001\u4f7f\u7528\u3059\u308b\u306e\u306f\u3001<\/p>\n<p><strong><code>query_posts()<\/code><\/strong><\/p>\n<p>\u30b5\u30d6\u30eb\u30fc\u30d7\u3092\u4f5c\u6210\uff08\u30aa\u30ea\u30b8\u30ca\u30eb\u306e\u30eb\u30fc\u30d7\u3092\u4f5c\u6210\u3001\u8907\u6570\u306e\u30eb\u30fc\u30d7\u3092\u4f5c\u6210\u3002\uff09\u3059\u308b\u969b\u306f\u4f7f\u7528\u3059\u308b\u306e\u306f\u3001<\/p>\n<p><strong><code>WP_Query()<\/code><\/strong><\/p>\n<p>\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<h4>query_posts() \u00a0\u30e1\u30a4\u30f3\u30eb\u30fc\u30d7<\/h4>\n<p>\u305d\u308c\u3067\u306f\u3001\u30e1\u30a4\u30f3\u30eb\u30fc\u30d7\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3059\u308bquery_posts()\u95a2\u6570\u306b\u3064\u3044\u3066\u306e\u4f7f\u7528\u65b9\u6cd5\u3092\u3002<br \/><strong>PHP<\/strong><\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">&lt;?php $args = array(\r\n     'category_name' =&gt; 'cat-hoge',\r\n     'posts_per_page' =&gt; 5,\u00a0\r\n); ?&gt;\r\n&lt;?php query_posts( $args ); ?&gt;\r\n&lt;?php if (have_posts()) : while (have_posts()) : the_post(); \/\/ \u30eb\u30fc\u30d7\u51e6\u7406\r\n   endwhile;\r\nelse;\r\n   \/\/ not found\r\nendif;\r\nwp_reset_query(); \/\/\u30af\u30a8\u30ea\u3092\u30ea\u30bb\u30c3\u30c8\r\n?&gt;<\/pre>\n<p>\u3068\u3056\u3063\u3068\u66f8\u304d\u307e\u3057\u305f\u304c\u3001\u8aac\u660e\u3092\u3002<\/p>\n<p>$args = arrey();\u306e\u914d\u5217\u3067\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u60c5\u5831\u3092\u6307\u5b9a\u3002<br \/><strong>&#8216;category_name&#8217;<\/strong>\u306f<strong>\u30ab\u30c6\u30b4\u30ea\u540d<\/strong>\u3001<strong>&#8216;post_per_page&#8217;<\/strong>\u306f<strong>\u4f55\u500b\u8a18\u4e8b\u3092\u8868\u793a\u3059\u308b\u304b<\/strong>\u3002\u306e\u6307\u5b9a\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><strong>query_post( $args );<\/strong>\u3067\u30e1\u30a4\u30f3\u306eWordPress\u30eb\u30fc\u30d7\u3092\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<p><strong>if(have_posts()) : while(have_posts()) : the_post();<\/strong>\u3067\u30eb\u30fc\u30d7\u306e\u958b\u59cb\u3002<\/p>\n<p><strong>\u300c\u8a72\u5f53\u3059\u308b\u8a18\u4e8b\u304c\u3042\u308b\u306a\u3089\u3070\u3001\u3042\u308b\u3060\u3051\u30eb\u30fc\u30d7\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u300d<\/strong>\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001<strong>&#8216;post_per_page&#8217; =&gt; 5;<\/strong>\u3068\u3057\u3066\u3044\u3044\u307e\u3059\u306e\u3067\u3001\u6700\u59275\u56de\u306e\u30eb\u30fc\u30d7\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3082\u3063\u3068\u7c21\u5358\u306b\u8a18\u8ff0\u3059\u308b\u306a\u3089<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">&lt;?php query_posts('category_name=hoge-cat,hoge-cat02&amp;showposts=10'); ?&gt;\r\n&lt;?php if(have_posts()):while(have_posts()):the_post(); \/\/ \u30eb\u30fc\u30d7\u51e6\u7406 ?&gt;\r\n&lt;?php endwhile;endif; ?&gt;\r\n<\/pre>\n<p>\u3053\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3002\u300c,\u300d\u3067\u30ab\u30c6\u30b4\u30ea\u3092\u8907\u6570\u6307\u5b9a\u3001\u300c&amp;\u300d\u6761\u4ef6\u3092\u8ffd\u52a0\u3002\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<h4><strong>WP_Query() \u30b5\u30d6\u30eb\u30fc\u30d7<\/strong><\/h4>\n<p>\u5148\u307b\u3069\u306f\u30e1\u30a4\u30f3\u30eb\u30fc\u30d7\u3067\u3057\u305f\u3002\u3067\u306f\u8907\u6570\u30eb\u30fc\u30d7\u3092\u4f7f\u3046\u5834\u5408\u306f\u3069\u3046\u3059\u308b\u304b\u3068\u8a00\u3046\u3068\u3001WP_Query()\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">&lt;?php $args = array(\r\n     'category_name' =&gt; 'cat-hoge',\r\n     'posts_per_page' =&gt; 5,\u00a0\r\n); ?&gt;\r\n&lt;?php $loop = new WP_Query( $args );\r\nif($loop -&gt; have_posts()): \u00a0while($loop -&gt; have_posts()): $loop -&gt; the_post();\r\n\u00a0 endwhile;\r\nelse;\r\n   \/\/ not found\r\nendif;\r\nwp_reset_postdata();\u00a0\/\/\u30af\u30a8\u30ea\u3092\u30ea\u30bb\u30c3\u30c8\r\n?&gt;<\/pre>\n<p>\u5148\u307b\u3069\u306e\u30e1\u30a4\u30f3\u30eb\u30fc\u30d7\u3068\u9055\u3046\u70b9\u306f new WP_Query( $args ); \u3068\u30af\u30a8\u30ea\u306e\u30ea\u30bb\u30c3\u30c8\u3067 wp_reset_postdata(); \u3067\u3059\u3002<\/p>\n<p>\u3061\u3068\u5206\u304b\u308a\u3084\u3059\u304f\u8a18\u8ff0\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php $args = array(\r\n     'category_name' =&gt; 'cat-hoge',\r\n     'posts_per_page' =&gt; 5,\u00a0\r\n); ?&gt;\r\n&lt;?php $loop = new WP_Query( $args ); ?&gt;\r\n  &lt;?php if($loop\u00a0-&gt; have_posts()): ?&gt;\r\n  &lt;?php while($loop\u00a0-&gt; have_posts()): $loop-&gt;the_post();?&gt;\r\n  &lt;?php endwhile; endif; ?&gt;\r\n&lt;?php wp_reset_postdata(); ?&gt;\r\n<\/pre>\n<p>\u3068\u3044\u3063\u305f\u611f\u3058\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>query_posts()\u95a2\u6570\u3068\u540c\u69d8<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">$loop = new WP_Query( 'category_name=hoge,hogege' );<\/pre>\n<p>\u3068\u8a18\u8ff0\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3059\u308b\u969b\u3001\u30ad\u30e2\u3068\u306a\u308b\u306e\u304cWordPress\u306e\u30eb\u30fc\u30d7\u304b\u3068\u601d\u3044\u307e\u3059\u3002 \u4eca\u56de\u306f\u305d\u306eWordPress\u306e\u30eb\u30fc\u30d7\u306b\u95a2\u3057\u3066\u307e\u3068\u3081\u3066\u307f\u307e\u3057\u305f\u3002 WordPress\u00a0\u30eb\u30fc\u30d7 wordpress\u306e\u30eb\u30fc\u30d7\u306e\u57fa\u790e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[180,173,111,115],"class_list":["post-3297","post","type-post","status-publish","format-standard","hentry","category-wordpress","tag-mysql","tag-php","tag-wordpress-2","tag-115"],"_links":{"self":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/3297","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3297"}],"version-history":[{"count":15,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/3297\/revisions"}],"predecessor-version":[{"id":3311,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/3297\/revisions\/3311"}],"wp:attachment":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3297"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}