{"id":1575,"date":"2018-11-05T21:20:50","date_gmt":"2018-11-05T12:20:50","guid":{"rendered":"http:\/\/4koma-web.com\/coding\/?p=1575"},"modified":"2018-11-05T21:20:50","modified_gmt":"2018-11-05T12:20:50","slug":"wp_is_mobile%e3%81%a7pc%e3%81%a8sp%e3%81%a7%e8%a1%a8%e7%a4%ba%e3%82%92%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e3%82%8b","status":"publish","type":"post","link":"https:\/\/4koma-web.com\/coding\/wp_is_mobile%e3%81%a7pc%e3%81%a8sp%e3%81%a7%e8%a1%a8%e7%a4%ba%e3%82%92%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e3%82%8b\/","title":{"rendered":"wp_is_mobile()\u3067PC\u3068SP\u3067\u8868\u793a\u3092\u5207\u308a\u66ff\u3048\u308b"},"content":{"rendered":"<p>WordPress\u306b\u306f\u6761\u4ef6\u5206\u5c90\u30bf\u30b0\u304c\u5b58\u5728\u3057\u307e\u3059\u3002<br \/>\n\u3053\u306e\u30bf\u30b0\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30c7\u30d0\u30a4\u30b9\u306b\u3088\u3063\u3066\u8868\u793a\u306e\u5909\u66f4\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p>\u305d\u308c\u304c\u3001wp_is_mobile\u3068\u3044\u3046\u6761\u4ef6\u5206\u5c90\u30bf\u30b0\u3067\u3059\u3002<br \/>\n\u30b9\u30de\u30db\u304b\u3089\u306e\u30a2\u30af\u30bb\u30b9\u3055\u308c\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a\u3057\u3001\u8868\u793a\u306e\u5207\u308a\u66ff\u3048\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<pre>\r\n<?php if ( wp_is_mobile() ) : ?>\r\n \/\/ \u30b9\u30de\u30db\u3067\u8868\u793a\u3055\u305b\u308b\u5185\u5bb9\r\n<?php else: ?>\r\n \/\/ PC\u3067\u8868\u793a\u3055\u305b\u308b\u5185\u5bb9\r\n<?php endif; ?>\r\n<\/pre>\n<p>PC\u3068\u30b9\u30de\u30db\u3067\u5225\u3005\u306e\u5e83\u544a\u3092\u8868\u793a\u3055\u305b\u308b\u3068\u304d\u3084\u3001<br \/>\nPC\u3068\u30b9\u30de\u30db\u3067\u30e1\u30cb\u30e5\u30fc\u306e\u8868\u793a\u306e\u4ed5\u65b9\u3092\u5909\u3048\u305f\u3044\u5834\u5408\u306b\u6709\u52b9\u3067\u3059\u3002<\/p>\n<p>\u30e1\u30c7\u30a3\u30a2\u30af\u30a8\u30ea\u30fc\u3068\u4f3c\u305f\u3088\u3046\u306b\u8868\u793a\u306e\u5207\u308a\u66ff\u3048\u304c\u53ef\u80fd\u3067\u3059\u304c\u3001wp_is_mobile()\u3067\u306f\u3001\u7aef\u672b\u306b\u3088\u3063\u3066\u5224\u5225\u3059\u308b\u3068\u3053\u308d\u304c\u5927\u304d\u304f\u9055\u3046\u3068\u3053\u308d\u3067\u3059\u3002<\/p>\n<p>\u6ce8\u610f\u70b9\u3068\u3057\u3066\u3001\u30bf\u30d6\u30ec\u30c3\u30c8\u3082\u30b9\u30de\u30db\u6271\u3044\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u305f\u3081\u3001\u30b9\u30de\u30db\u4ee5\u5916\u306fPC\u8868\u793a\u306b\u3057\u305f\u3044\u3044\u5834\u5408\u306f\u3001<br \/>\nfunction.php\u306b\u4ee5\u4e0b\u306e\u8a18\u8ff0\u3092\u3057\u3066\u3001is_mobile()\u3067\u6761\u4ef6\u5206\u5c90\u3092\u3057\u3066\u3042\u3052\u307e\u3059\u3002<\/p>\n<pre>\r\nfunction is_mobile(){\r\n    $useragents = array(\r\n        'iPhone', \/\/ iPhone\r\n        'iPod', \/\/ iPod touch\r\n        'Android.*Mobile', \/\/ 1.5+ Android *** Only mobile\r\n        'Windows.*Phone', \/\/ *** Windows Phone\r\n        'dream', \/\/ Pre 1.5 Android\r\n        'CUPCAKE', \/\/ 1.5+ Android\r\n        'blackberry9500', \/\/ Storm\r\n        'blackberry9530', \/\/ Storm\r\n        'blackberry9520', \/\/ Storm v2\r\n        'blackberry9550', \/\/ Storm v2\r\n        'blackberry9800', \/\/ Torch\r\n        'webOS', \/\/ Palm Pre Experimental\r\n        'incognito', \/\/ Other iPhone browser\r\n        'webmate' \/\/ Other iPhone browser\r\n \r\n    );\r\n    $pattern = '\/'.implode('|', $useragents).'\/i';\r\n    return preg_match($pattern, $_SERVER['HTTP_USER_AGENT']);\r\n}\r\n\r\n\r\n<?php if ( is_mobile() ) : ?>\r\n  \/\/ \u30b9\u30de\u30db\u3067\u8868\u793a\u3055\u305b\u308b\u5185\u5bb9\r\n<?php else: ?>\r\n  \/\/ \u30b9\u30de\u30db\u4ee5\u5916\u3067\u3067\u8868\u793a\u3055\u305b\u308b\u5185\u5bb9\r\n<?php endif; ?>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>WordPress\u306b\u306f\u6761\u4ef6\u5206\u5c90\u30bf\u30b0\u304c\u5b58\u5728\u3057\u307e\u3059\u3002 \u3053\u306e\u30bf\u30b0\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30c7\u30d0\u30a4\u30b9\u306b\u3088\u3063\u3066\u8868\u793a\u306e\u5909\u66f4\u304c\u53ef\u80fd\u3067\u3059\u3002 \u305d\u308c\u304c\u3001wp_is_mobile\u3068\u3044\u3046\u6761\u4ef6\u5206\u5c90\u30bf\u30b0\u3067\u3059\u3002 \u30b9\u30de\u30db\u304b\u3089\u306e\u30a2\u30af\u30bb\u30b9\u3055\u308c\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a\u3057 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"","_original_post":"","footnotes":""},"categories":[1],"tags":[],"publishpress_future_action":{"enabled":false,"date":"2026-04-21 23:03:59","action":"change-status","newStatus":"draft","terms":[],"taxonomy":"category"},"_links":{"self":[{"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/posts\/1575"}],"collection":[{"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/comments?post=1575"}],"version-history":[{"count":0,"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/posts\/1575\/revisions"}],"wp:attachment":[{"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/media?parent=1575"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/categories?post=1575"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/4koma-web.com\/coding\/wp-json\/wp\/v2\/tags?post=1575"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}