{"id":74,"date":"2021-07-28T13:40:07","date_gmt":"2021-07-28T04:40:07","guid":{"rendered":"http:\/\/gaku-on.com\/?p=74"},"modified":"2021-07-28T13:40:07","modified_gmt":"2021-07-28T04:40:07","slug":"%e8%b6%85%e7%a2%ba%e5%ae%9a%e7%89%88%e3%80%80%e3%82%bf%e3%82%b0%e3%81%a8%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e3%81%a7%e3%83%81%e3%82%a7%e3%83%83%e3%82%af%e3%83%9c%e3%83%83%e3%82%af%e3%82%b9%e6%a4%9c","status":"publish","type":"post","link":"http:\/\/gaku-on.com\/?p=74","title":{"rendered":"\u8d85\u78ba\u5b9a\u7248\u3000\u30bf\u30b0\u3068\u30ab\u30c6\u30b4\u30ea\u3067\u30c1\u30a7\u30c3\u30af\u30dc\u30c3\u30af\u30b9\u691c\u7d22\uff01\uff01"},"content":{"rendered":"\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-\u30a4\u30e9\u30b9\u30c8\u30b9\u30a4\u30c3\u30c1 wp-block-embed-\u30a4\u30e9\u30b9\u30c8\u30b9\u30a4\u30c3\u30c1\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"8nalsQUGvd\"><a href=\"https:\/\/illustswitch.com\/wordpress-search-filter\/\">WordPress\u306b\u7d5e\u308a\u8fbc\u307f\u691c\u7d22\u3092\u5b9f\u88c5\u3059\u308b\u3010\u30d7\u30e9\u30b0\u30a4\u30f3\u7121\u3057\u3011<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;WordPress\u306b\u7d5e\u308a\u8fbc\u307f\u691c\u7d22\u3092\u5b9f\u88c5\u3059\u308b\u3010\u30d7\u30e9\u30b0\u30a4\u30f3\u7121\u3057\u3011&#8221; &#8212; \u30a4\u30e9\u30b9\u30c8\u30b9\u30a4\u30c3\u30c1\" src=\"https:\/\/illustswitch.com\/wordpress-search-filter\/embed\/#?secret=8nalsQUGvd\" data-secret=\"8nalsQUGvd\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>\u4e0a\u8a18\u306b\u3057\u305f\u304c\u3063\u3066\u3084\u3063\u305f<\/p>\n\n\n\n<p>\u30d7\u30e9\u30b0\u30a4\u30f3+function\u306b\u8ffd\u52a0\u3059\u308b<\/p>\n\n\n\n<p><strong>\u691c\u7d22\u306e\u90e8\u5206\u306f<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;form role=\"search\" method=\"get\" id=\"searchform\" action=\"&lt;?php echo esc_url(home_url('\/')); ?>\">\r\n\r\n&lt;h2>\u30ab\u30c6\u30b4\u30ea\u30fc&lt;\/h2>\r\n&lt;?php\r\n$category_args = array(\r\n\t'orderby' => 'name',\r\n\t'order' => 'ASC',\r\n);\r\n$categories = get_terms( 'category', $category_args );\r\nforeach($categories as $category) :\r\n?>\r\n&lt;label>&lt;input type=\"checkbox\" name=\"get_cats&#91;]\" value=\"&lt;?php echo $category->slug; ?>\">&lt;?php echo $category->name; ?>&lt;\/label>\r\n&lt;?php endforeach; ?>\r\n\r\n&lt;h2>\u30bf\u30b0&lt;\/h2>\r\n&lt;?php\r\n$post_tag_args = array(\r\n\t'orderby' => 'name',\r\n\t'order' => 'ASC',\r\n);\r\n$post_tags = get_terms( 'post_tag', $post_tag_args );\r\nforeach($post_tags as $post_tag) :\r\n?>\r\n&lt;label>&lt;input type=\"checkbox\" name=\"get_tags&#91;]\" value=\"&lt;?php echo $post_tag->slug; ?>\">&lt;?php echo $post_tag->name; ?>&lt;\/label>\r\n&lt;?php endforeach; ?>\r\n\r\n&lt;h2>&lt;?php _x( 'Search for:', 'label' ); ?>\u30ad\u30fc\u30ef\u30fc\u30c9&lt;\/h2>\r\n&lt;input type=\"text\" value=\"&lt;?php echo get_search_query(); ?>\" name=\"s\" id=\"s\" placeholder=\"\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\" \/>\r\n\r\n\r\n&lt;input type=\"submit\" value=\"\u691c\u7d22\" \/>\r\n&lt;\/form><\/code><\/pre>\n\n\n\n<p><strong>\u691c\u7d22\u7d50\u679c\u3000serch.php\u3092\u3054\u3063\u305d\u308a\u4ee5\u4e0b\u306b\u30b3\u30d4\u30da<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\r\n\/**\r\n * The template for displaying search results pages.\r\n *\r\n * @link https:\/\/developer.wordpress.org\/themes\/basics\/template-hierarchy\/#search-result\r\n *\r\n * @package wpindex\r\n *\/\r\n\r\nget_header(); ?>\r\n\r\n    &lt;section id=\"primary\" class=\"content-area\">\r\n        &lt;main id=\"main\" class=\"site-main\" role=\"main\">\r\n\r\n        \r\n\r\n&lt;?php\r\n$s = $_GET&#91;'s'];\r\n$get_cats = $_GET&#91;'get_cats'];\r\n$get_tags = $_GET&#91;'get_tags'];\r\n\r\nif($get_cats) {\r\n    $tax_ary&#91;] = array(\r\n        'taxonomy' => 'category',\r\n        'field' => 'slug',\r\n        'terms' => $get_cats,\r\n        'operator' => 'IN', \/\/AND\u304bIN\r\n    );\r\n}\r\nif($get_tags) {\r\n    $tax_ary&#91;] = array(\r\n        'taxonomy' => 'post_tag',\r\n        'field' => 'slug',\r\n        'terms' => $get_tags,\r\n        'operator' => 'IN', \/\/AND\u304bIN\r\n    );\r\n}\r\n?>\r\n&lt;?php if (!($s || $get_cats || $get_tags)): ?>\r\n    &lt;p>\u691c\u7d22\u6761\u4ef6\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044&lt;\/p>\r\n    &lt;?php get_search_form(); ?>\r\n&lt;?php else: ?>\r\n\r\n&lt;h1>\u691c\u7d22\u7d50\u679c&lt;\/h1>\r\n&lt;?php\r\nif(is_array($get_cats)) {\r\n    echo '&lt;p>\u30ab\u30c6\u30b4\u30ea\u30fc:';\r\n    foreach ($get_cats as $val) {\r\n        $p_term = get_term_by('slug', $val, 'category');\r\n        echo $p_term->name;\r\n        if ($val !== end($get_cats)) {\r\n            echo ', ';\r\n        }\r\n    }\r\n    echo '&lt;\/p>';\r\n} ?>\r\n&lt;?php\r\nif(is_array($get_tags)) {\r\n    echo '&lt;p>\u30bf\u30b0:';\r\n    foreach ($get_tags as $val) {\r\n        $s_term = get_term_by('slug', $val, 'post_tag');\r\n        echo $s_term->name;\r\n        if ($val !== end($get_tags)) {\r\n            echo ', ';\r\n        }\r\n    }\r\n    echo '&lt;\/p>';\r\n} ?>\r\n&lt;?php\r\nif($s) { echo '&lt;p>\u30ad\u30fc\u30ef\u30fc\u30c9:'.$s.'&lt;\/p>'; } ?>\r\n\r\n&lt;?php\r\n    $my_query = new WP_Query( array(\r\n        'paged' => get_query_var('paged'),\r\n        'post_type' => 'post',\r\n        'tax_query' => $tax_ary,\r\n        'relation' => 'AND', \/\/AND\u304bOR\r\n        's' => $s,\r\n)); ?>\r\n&lt;?php if($my_query->have_posts() ) : ?>\r\n&lt;ul>\r\n&lt;?php while( $my_query->have_posts()) : $my_query->the_post(); ?>\r\n&lt;li>&lt;a href=\"&lt;?php the_permalink() ?>\">&lt;?php the_title(); ?>&lt;\/a>\r\n&lt;\/li>\r\n&lt;?php endwhile; ?>\r\n&lt;\/ul>\r\n&lt;?php else: ?>\r\n&lt;p>\u7d50\u679c\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002&lt;\/p>\r\n&lt;?php endif; ?>\r\n\r\n&lt;?php endif; ?>\r\n\r\n        &lt;\/main>&lt;!-- #main -->\r\n    &lt;\/section>&lt;!-- #primary -->\r\n\r\n&lt;?php\r\nget_sidebar();\r\nget_footer();<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0a\u8a18\u306b\u3057\u305f\u304c\u3063\u3066\u3084\u3063\u305f \u30d7\u30e9\u30b0\u30a4\u30f3+functio&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,1],"tags":[],"class_list":["post-74","post","type-post","status-publish","format-standard","hentry","category-5","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/gaku-on.com\/index.php?rest_route=\/wp\/v2\/posts\/74","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/gaku-on.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/gaku-on.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/gaku-on.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/gaku-on.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=74"}],"version-history":[{"count":1,"href":"http:\/\/gaku-on.com\/index.php?rest_route=\/wp\/v2\/posts\/74\/revisions"}],"predecessor-version":[{"id":75,"href":"http:\/\/gaku-on.com\/index.php?rest_route=\/wp\/v2\/posts\/74\/revisions\/75"}],"wp:attachment":[{"href":"http:\/\/gaku-on.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=74"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/gaku-on.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=74"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/gaku-on.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=74"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}