{"id":8404,"date":"2025-08-07T12:34:19","date_gmt":"2025-08-07T03:34:19","guid":{"rendered":"https:\/\/code-plus.jp\/gp\/?p=8404"},"modified":"2026-01-08T11:17:12","modified_gmt":"2026-01-08T02:17:12","slug":"body-idclass-8404","status":"publish","type":"post","link":"https:\/\/code-plus.jp\/gp\/body-idclass-8404\/","title":{"rendered":"\u3010WordPress\u3011body\u306eid\u306b\u30b9\u30e9\u30c3\u30b0\u540d\u3001body_class\u306b\u4efb\u610f\u306e\u30af\u30e9\u30b9\u3092\u8ffd\u52a0\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>WordPress\u3067\u30b5\u30a4\u30c8\u3092\u5236\u4f5c\u3057\u3066\u3044\u308b\u3068\u3001\u30da\u30fc\u30b8\u3054\u3068\u306b\u7570\u306a\u308bCSS\u3092\u9069\u7528\u3057\u305f\u3044\u30b1\u30fc\u30b9\u304c\u3088\u304f\u3042\u308a\u307e\u3059\u3002\u305d\u3093\u306a\u6642\u306b\u4fbf\u5229\u306a\u306e\u304c\u3001<code>&lt;body&gt;<\/code>\u30bf\u30b0\u306bID\u3084\u30af\u30e9\u30b9\u3092\u8ffd\u52a0\u3059\u308b\u65b9\u6cd5\u3067\u3059\u3002<\/p>\r\n<p>\u30cd\u30c3\u30c8\u3067\u300cWordPress body id \u30b9\u30e9\u30c3\u30b0\u300d\u3068\u691c\u7d22\u3059\u308b\u3068\u3001\u591a\u304f\u306e\u30b5\u30a4\u30c8\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u304c\u7d39\u4ecb\u3055\u308c\u3066\u3044\u307e\u3059\uff1a<\/p>\r\n\r\n<pre><code class=\"language-php\">&lt;body id=&#39;&lt;?php echo esc_attr($post-&gt;post_name); ?&gt;&#39;&gt;\r\n<\/code><\/pre>\r\n<p>\u5b9f\u306f\u3053\u306e\u30b3\u30fc\u30c9\u3001<b class=\"fw-600\">404\u30da\u30fc\u30b8\u3084\u30a2\u30fc\u30ab\u30a4\u30d6\u30da\u30fc\u30b8\u3067\u306f\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3059<\/b>\u3002<br class=\"d-none_sp\" \/>\r\n\u4eca\u56de\u306f\u306a\u305c\u30a8\u30e9\u30fc\u304c\u8d77\u304d\u308b\u306e\u304b\u3001\u305d\u3057\u3066\u3069\u3046\u3059\u308c\u3070\u6b63\u3057\u304f\u5b9f\u88c5\u3067\u304d\u308b\u306e\u304b\u3092\u3001\u521d\u5fc3\u8005\u306e\u65b9\u306b\u3082\u308f\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\r\n\r\n<!-- \u2605\u76ee\u6b21\u30ea\u30b9\u30c8 -->\r\n<ul class=\"tocList\" data-toc-id=\"js-tocBWGD\" style=\"height:28rem;\"><\/ul>\r\n<ins class=\"tocBtn is-fixed\" data-toc-id=\"js-tocBWGD\"><\/ins>\r\n\r\n\r\n\r\n\r\n\r\n\r\n<h2 class=\"fz-xl\">\u306a\u305c\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u306e\u304b\uff1f<\/h2>\r\n<h3 class=\"fz-lg\">\u3088\u304f\u3042\u308b\u9593\u9055\u3063\u305f\u30b3\u30fc\u30c9<\/h3>\r\n<pre><code class=\"language-php\">&lt;body id=&#39;&lt;?php echo esc_attr($post-&gt;post_name); ?&gt;&#39; &lt;?php body_class(); ?&gt;&gt;\r\n<\/code><\/pre>\r\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3092\u4f7f\u3046\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30a8\u30e9\u30fc\u30ed\u30b0\u304c\u8a18\u9332\u3055\u308c\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\uff1a<\/p>\r\n<pre><code class=\"language-\">PHP Warning: Attempt to read property &quot;post_name&quot; on null in \/path\/to\/header.php on line XXX\r\n<\/code><\/pre>\r\n<h3 class=\"fz-lg\">\u30a8\u30e9\u30fc\u306e\u539f\u56e0<\/h3>\r\n<p>\u3053\u306e\u30a8\u30e9\u30fc\u306f\u3001<code>$post<\/code>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c<code>null<\/code>\uff08\u5b58\u5728\u3057\u306a\u3044\uff09\u5834\u5408\u306b\u767a\u751f\u3057\u307e\u3059\u3002WordPress\u3067\u306f\u3001\u3059\u3079\u3066\u306e\u30da\u30fc\u30b8\u3067<code>$post<\/code>\u304c\u5b58\u5728\u3059\u308b\u308f\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\r\n<p><b class=\"fw-600\"><code>$post<\/code>\u304c\u5b58\u5728\u3057\u306a\u3044\u30da\u30fc\u30b8\u306e\u4f8b\uff1a<\/b><\/p>\r\n<ul style=\"list-style-type:bullet;\">\r\n  <li>404\u30a8\u30e9\u30fc\u30da\u30fc\u30b8<\/li>\r\n  <li>\u30ab\u30c6\u30b4\u30ea\u30fc\u30a2\u30fc\u30ab\u30a4\u30d6\u30da\u30fc\u30b8<\/li>\r\n  <li>\u30bf\u30b0\u30a2\u30fc\u30ab\u30a4\u30d6\u30da\u30fc\u30b8<\/li>\r\n  <li>\u691c\u7d22\u7d50\u679c\u30da\u30fc\u30b8<\/li>\r\n  <li>\u6295\u7a3f\u4e00\u89a7\u30da\u30fc\u30b8\uff08\u30d6\u30ed\u30b0\u30c8\u30c3\u30d7\uff09<\/li>\r\n<\/ul>\r\n<p>\u3053\u308c\u3089\u306e\u30da\u30fc\u30b8\u3067\u306f<code>$post<\/code>\u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3001<code>$post-&gt;post_name<\/code>\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308b\u306e\u3067\u3059\u3002<\/p>\r\n<h2 class=\"fz-xl\">body_class()\u95a2\u6570\u306b\u3064\u3044\u3066<\/h2>\r\n<p>\u307e\u305a\u3001WordPress\u306b\u6a19\u6e96\u3067\u7528\u610f\u3055\u308c\u3066\u3044\u308b<code>body_class()<\/code>\u95a2\u6570\u306b\u3064\u3044\u3066\u7406\u89e3\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\r\n<h3 class=\"fz-lg\">body_class()\u306e\u57fa\u672c<\/h3>\r\n<p><code>body_class()<\/code>\u306f\u3001\u73fe\u5728\u8868\u793a\u3057\u3066\u3044\u308b\u30da\u30fc\u30b8\u306e\u7a2e\u985e\u306b\u5fdc\u3058\u3066\u3001\u81ea\u52d5\u7684\u306b\u9069\u5207\u306a\u30af\u30e9\u30b9\u3092<code>&lt;body&gt;<\/code>\u30bf\u30b0\u306b\u8ffd\u52a0\u3057\u3066\u304f\u308c\u308b\u4fbf\u5229\u306a\u95a2\u6570\u3067\u3059\u3002<\/p>\r\n<pre><code class=\"language-php\">&lt;body &lt;?php body_class(); ?&gt;&gt;\r\n<\/code><\/pre>\r\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u306f\u3001\u4f8b\u3048\u3070\u56fa\u5b9a\u30da\u30fc\u30b8\u306a\u3089\u4ee5\u4e0b\u306e\u3088\u3046\u306aHTML\u3092\u51fa\u529b\u3057\u307e\u3059\uff1a<\/p>\r\n<pre><code class=\"language-html\">&lt;body class=&quot;page page-id-2 page-template-default&quot;&gt;\r\n<\/code><\/pre>\r\n<h3 class=\"fz-lg\">body_class()\u306b\u4efb\u610f\u306e\u30af\u30e9\u30b9\u3092\u8ffd\u52a0\u3059\u308b<\/h3>\r\n<p><code>body_class()<\/code>\u95a2\u6570\u306b\u306f\u3001\u72ec\u81ea\u306e\u30af\u30e9\u30b9\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\uff1a<\/p>\r\n<pre><code class=\"language-php\">&lt;?php\r\n$my_class = &#39;my-custom-class another-class&#39;;\r\n?&gt;\r\n&lt;body &lt;?php body_class($my_class); ?&gt;&gt;\r\n<\/code><\/pre>\r\n<p>\u51fa\u529b\u7d50\u679c\uff1a<\/p>\r\n<pre><code class=\"language-html\">&lt;body class=&quot;page page-id-2 page-template-default my-custom-class another-class&quot;&gt;\r\n<\/code><\/pre>\r\n<h2 class=\"fz-xl\">\u6b63\u3057\u3044\u5b9f\u88c5\u65b9\u6cd5<\/h2>\r\n<p>\u305d\u308c\u3067\u306f\u3001\u30a8\u30e9\u30fc\u3092\u56de\u907f\u3057\u306a\u304c\u3089\u3001body\u30bf\u30b0\u306bID\u3068\u30af\u30e9\u30b9\u3092\u9069\u5207\u306b\u8ffd\u52a0\u3059\u308b\u65b9\u6cd5\u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\r\n<h3 class=\"fz-lg\">\u57fa\u672c\u7684\u306a\u5b9f\u88c5<\/h3>\r\n<pre><code class=\"language-php\">&lt;?php\r\n\/\/\u521d\u671f\u5024\u306e\u8a2d\u5b9a\r\n$body_id = &#39;&#39;;\r\n$body_addclass = &#39;&#39;;\r\n\r\n\/\/\u30da\u30fc\u30b8\u30bf\u30a4\u30d7\u3054\u3068\u306bID\u3092\u8a2d\u5b9a\r\nif (is_singular()) {\r\n    \/\/\u6295\u7a3f\u30fb\u56fa\u5b9a\u30da\u30fc\u30b8\u306e\u5834\u5408\r\n    global $post;\r\n    if ($post &amp;&amp; isset($post-&gt;post_name)) {\r\n        $body_id = esc_attr($post-&gt;post_name);\r\n    }\r\n} elseif (is_404()) {\r\n    \/\/404\u30da\u30fc\u30b8\u306e\u5834\u5408\r\n    $body_id = &#39;error-404&#39;;\r\n} elseif (is_search()) {\r\n    \/\/\u691c\u7d22\u7d50\u679c\u30da\u30fc\u30b8\u306e\u5834\u5408\r\n    $body_id = &#39;search-results&#39;;\r\n}\r\n\r\n\/\/\u4efb\u610f\u306e\u30af\u30e9\u30b9\u3092\u8ffd\u52a0\uff08\u4f8b\uff1a\u30c6\u30fc\u30de\u540d\uff09\r\n$body_addclass = &#39;my-theme-name&#39;;\r\n?&gt;\r\n&lt;body id=&#39;&lt;?php echo $body_id; ?&gt;&#39; &lt;?php body_class($body_addclass); ?&gt;&gt;\r\n<\/code><\/pre>\r\n<h3 class=\"fz-lg\">\u3088\u308a\u8a73\u7d30\u306a\u5b9f\u88c5\u4f8b<\/h3>\r\n<p>\u3059\u3079\u3066\u306e\u30da\u30fc\u30b8\u30bf\u30a4\u30d7\u306b\u5bfe\u5fdc\u3057\u305f\u3001\u3088\u308a\u5b8c\u5168\u306a\u5b9f\u88c5\u4f8b\u3067\u3059\uff1a<\/p>\r\n<pre><code class=\"language-php\">&lt;?php\r\n\/* ===================================\r\n * body\u8981\u7d20\u306e\u8a2d\u5b9a\r\n * =================================== *\/\r\n\r\n\/\/\u521d\u671f\u5024\u306e\u8a2d\u5b9a\r\n$body_id = &#39;&#39;;\r\n$body_addclass = &#39;&#39;;\r\n\r\n\/\/\u30da\u30fc\u30b8\u30bf\u30a4\u30d7\u3054\u3068\u306bID\u3092\u8a2d\u5b9a\r\nif (is_singular()) {\r\n    \/\/\u6295\u7a3f\u30fb\u56fa\u5b9a\u30da\u30fc\u30b8\r\n    global $post;\r\n    if ($post &amp;&amp; isset($post-&gt;post_name)) {\r\n        $body_id = esc_attr($post-&gt;post_name);\r\n    }\r\n} elseif (is_category() || is_tag() || is_tax()) {\r\n    \/\/\u30ab\u30c6\u30b4\u30ea\u30fc\u30fb\u30bf\u30b0\u30fb\u30ab\u30b9\u30bf\u30e0\u30bf\u30af\u30bd\u30ce\u30df\u30fc\r\n    $term = get_queried_object();\r\n    if ($term &amp;&amp; isset($term-&gt;slug)) {\r\n        $body_id = &#39;archive-&#39; . esc_attr($term-&gt;slug);\r\n    }\r\n} elseif (is_post_type_archive()) {\r\n    \/\/\u30ab\u30b9\u30bf\u30e0\u6295\u7a3f\u30bf\u30a4\u30d7\u30a2\u30fc\u30ab\u30a4\u30d6\r\n    $body_id = &#39;archive-&#39; . esc_attr(get_post_type());\r\n} elseif (is_home()) {\r\n    \/\/\u30d6\u30ed\u30b0\u6295\u7a3f\u4e00\u89a7\u30da\u30fc\u30b8\r\n    $body_id = &#39;home&#39;;\r\n} elseif (is_front_page()) {\r\n    \/\/\u30d5\u30ed\u30f3\u30c8\u30da\u30fc\u30b8\r\n    $body_id = &#39;front&#39;;\r\n} elseif (is_404()) {\r\n    \/\/404\u30a8\u30e9\u30fc\u30da\u30fc\u30b8\r\n    $body_id = &#39;error-404&#39;;\r\n} elseif (is_search()) {\r\n    \/\/\u691c\u7d22\u7d50\u679c\u30da\u30fc\u30b8\r\n    $body_id = &#39;search-results&#39;;\r\n} else {\r\n    \/\/\u305d\u306e\u4ed6\u306e\u30da\u30fc\u30b8\r\n    $body_id = &#39;default&#39;;\r\n}\r\n\r\n\/\/\u30c6\u30fc\u30de\u540d\u306a\u3069\u306e\u56fa\u5b9a\u30af\u30e9\u30b9\u3092\u8ffd\u52a0\r\n$theme_name = &#39;my-theme&#39;;\r\n$body_addclass = $theme_name;\r\n\r\n\/\/\u7279\u5b9a\u306e\u6761\u4ef6\u3067\u8ffd\u52a0\u30af\u30e9\u30b9\u3092\u8a2d\u5b9a\uff08\u4f8b\uff1a\u30e2\u30d0\u30a4\u30eb\u5224\u5b9a\u306a\u3069\uff09\r\nif (wp_is_mobile()) {\r\n    $body_addclass .= &#39; is-mobile&#39;;\r\n}\r\n\r\n\/\/\u4f59\u5206\u306a\u7a7a\u767d\u3092\u524a\u9664\r\n$body_addclass = trim($body_addclass);\r\n?&gt;\r\n&lt;body id=&#39;&lt;?php echo $body_id; ?&gt;&#39; &lt;?php body_class($body_addclass); ?&gt;&gt;\r\n<\/code><\/pre>\r\n<h2 class=\"fz-xl\">\u30ab\u30b9\u30bf\u30e0\u30bf\u30af\u30bd\u30ce\u30df\u30fc\u306e\u30bf\u30fc\u30e0\u3092\u30af\u30e9\u30b9\u306b\u8ffd\u52a0\u3059\u308b<\/h2>\r\n<p>\u30ab\u30b9\u30bf\u30e0\u30bf\u30af\u30bd\u30ce\u30df\u30fc\uff08\u4f8b\uff1a<code>pg<\/code>\u3068\u3044\u3046\u30bf\u30af\u30bd\u30ce\u30df\u30fc\uff09\u306e\u30bf\u30fc\u30e0\u3092body\u30af\u30e9\u30b9\u306b\u8ffd\u52a0\u3057\u305f\u3044\u5834\u5408\uff1a<\/p>\r\n<pre><code class=\"language-php\">&lt;?php\r\n\/\/\u30ab\u30b9\u30bf\u30e0\u30bf\u30af\u30bd\u30ce\u30df\u30fc&#39;pg&#39;\u306e\u30bf\u30fc\u30e0\u3092\u30af\u30e9\u30b9\u306b\u8ffd\u52a0\r\n$term_slug_pg = &#39;&#39;;\r\n\r\nif (is_singular()) {\r\n    global $post;\r\n    if (isset($post) &amp;&amp; $post) {\r\n        \/\/&#39;pg&#39;\u30bf\u30af\u30bd\u30ce\u30df\u30fc\u306e\u30bf\u30fc\u30e0\u3092\u53d6\u5f97\r\n        $terms_pg = get_the_terms($post-&gt;ID, &#39;pg&#39;);\r\n        \r\n        \/\/\u30a8\u30e9\u30fc\u30c1\u30a7\u30c3\u30af\u3092\u542b\u3081\u3066\u51e6\u7406\r\n        if ($terms_pg &amp;&amp; !is_wp_error($terms_pg)) {\r\n            foreach ($terms_pg as $term_pg) {\r\n                $term_slug_pg = $term_pg-&gt;slug;\r\n                break; \/\/\u6700\u521d\u306e1\u3064\u3060\u3051\u53d6\u5f97\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n\/\/body\u30af\u30e9\u30b9\u306b\u8ffd\u52a0\r\n$body_addclass = trim($body_addclass . &#39; &#39; . $term_slug_pg);\r\n?&gt;\r\n<\/code><\/pre>\r\n<h2 class=\"fz-xl\">functions.php\u3067\u95a2\u6570\u5316\u3059\u308b\u65b9\u6cd5<\/h2>\r\n<p>\u30b3\u30fc\u30c9\u3092\u6574\u7406\u3057\u305f\u3044\u5834\u5408\u306f\u3001functions.php\u306b\u95a2\u6570\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\uff1a<\/p>\r\n<pre><code class=\"language-php\">\/\/functions.php \u306b\u8ffd\u52a0\r\nfunction get_custom_body_id() {\r\n    if (is_singular()) {\r\n        global $post;\r\n        if ($post &amp;&amp; isset($post-&gt;post_name)) {\r\n            return esc_attr($post-&gt;post_name);\r\n        }\r\n    } elseif (is_category() || is_tag() || is_tax()) {\r\n        $term = get_queried_object();\r\n        if ($term &amp;&amp; isset($term-&gt;slug)) {\r\n            return &#39;archive-&#39; . esc_attr($term-&gt;slug);\r\n        }\r\n    } elseif (is_404()) {\r\n        return &#39;error-404&#39;;\r\n    } elseif (is_search()) {\r\n        return &#39;search-results&#39;;\r\n    }\r\n    \r\n    return &#39;&#39;;\r\n}\r\n\r\n\/\/header.php \u3067\u306e\u4f7f\u7528\r\n&lt;body id=&#39;&lt;?php echo get_custom_body_id(); ?&gt;&#39; &lt;?php body_class(&#39;my-theme&#39;); ?&gt;&gt;\r\n<\/code><\/pre>\r\n<h2 class=\"fz-xl\">CSS\u3067\u306e\u6d3b\u7528\u4f8b<\/h2>\r\n<p>\u8a2d\u5b9a\u3057\u305fID\u3084\u30af\u30e9\u30b9\u3092\u4f7f\u3063\u3066\u3001\u30da\u30fc\u30b8\u3054\u3068\u306b\u7570\u306a\u308b\u30b9\u30bf\u30a4\u30eb\u3092\u9069\u7528\u3067\u304d\u307e\u3059\uff1a<\/p>\r\n<pre><code class=\"language-css\">\/* \u7279\u5b9a\u306e\u56fa\u5b9a\u30da\u30fc\u30b8\u306e\u307f\u306e\u30b9\u30bf\u30a4\u30eb *\/\r\n#about .header {\r\n    background-color: #f0f0f0;\r\n}\r\n\r\n\/* \u30ab\u30c6\u30b4\u30ea\u30fc\u30a2\u30fc\u30ab\u30a4\u30d6\u30da\u30fc\u30b8\u306e\u30b9\u30bf\u30a4\u30eb *\/\r\n#archive-news article {\r\n    border-left: 3px solid #0073aa;\r\n}\r\n\r\n\/* 404\u30da\u30fc\u30b8\u306e\u30b9\u30bf\u30a4\u30eb *\/\r\n#error-404 .content {\r\n    text-align: center;\r\n    padding: 100px 20px;\r\n}\r\n\r\n\/* body_class\u3067\u81ea\u52d5\u4ed8\u4e0e\u3055\u308c\u308b\u30af\u30e9\u30b9\u3092\u4f7f\u7528 *\/\r\n.home .header {\r\n    height: 500px; \/* \u30c8\u30c3\u30d7\u30da\u30fc\u30b8\u306e\u307f\u30d8\u30c3\u30c0\u30fc\u3092\u5927\u304d\u304f *\/\r\n}\r\n\r\n.single-post .sidebar {\r\n    display: none; \/* \u6295\u7a3f\u30da\u30fc\u30b8\u3067\u306f\u30b5\u30a4\u30c9\u30d0\u30fc\u3092\u975e\u8868\u793a *\/\r\n}\r\n<\/code><\/pre>\r\n<h2 class=\"fz-xl\">\u307e\u3068\u3081<\/h2>\r\n<p>WordPress\u3067<code>&lt;body&gt;<\/code>\u30bf\u30b0\u306bID\u3084\u30af\u30e9\u30b9\u3092\u8ffd\u52a0\u3059\u308b\u969b\u306f\u3001\u4ee5\u4e0b\u306e\u30dd\u30a4\u30f3\u30c8\u3092\u62bc\u3055\u3048\u307e\u3057\u3087\u3046\uff1a<\/p>\r\n<ol style=\"list-style-type:decimal;\">\r\n  <li>\r\n    <p><b class=\"fw-600\"><code>$post<\/code>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u5b58\u5728\u3092\u5fc5\u305a\u78ba\u8a8d\u3059\u308b<\/b><\/p>\r\n    <ul style=\"list-style-type:bullet;\">\r\n      <li><code>if ($post &amp;&amp; isset($post-&gt;post_name))<\/code>\u306e\u3088\u3046\u306b\u30c1\u30a7\u30c3\u30af<\/li>\r\n    <\/ul>\r\n  <\/li>\r\n  <li>\r\n    <p><b class=\"fw-600\">\u30da\u30fc\u30b8\u30bf\u30a4\u30d7\u3054\u3068\u306b\u9069\u5207\u306a\u51e6\u7406\u3092\u884c\u3046<\/b><\/p>\r\n    <ul style=\"list-style-type:bullet;\">\r\n      <li><code>is_singular()<\/code>\u3001<code>is_404()<\/code>\u306a\u3069\u306e\u6761\u4ef6\u5206\u5c90\u95a2\u6570\u3092\u6d3b\u7528<\/li>\r\n    <\/ul>\r\n  <\/li>\r\n  <li>\r\n    <p><b class=\"fw-600\">body_class()\u95a2\u6570\u3092\u6d3b\u7528\u3059\u308b<\/b><\/p>\r\n    <ul style=\"list-style-type:bullet;\">\r\n      <li>WordPress\u304c\u81ea\u52d5\u3067\u4ed8\u4e0e\u3059\u308b\u30af\u30e9\u30b9\u3082\u6709\u52b9\u6d3b\u7528<\/li>\r\n    <\/ul>\r\n  <\/li>\r\n  <li>\r\n    <p><b class=\"fw-600\">\u30a8\u30b9\u30b1\u30fc\u30d7\u51e6\u7406\u3092\u5fd8\u308c\u306a\u3044<\/b><\/p>\r\n    <ul style=\"list-style-type:bullet;\">\r\n      <li><code>esc_attr()<\/code>\u3067\u5c5e\u6027\u5024\u3092\u30a8\u30b9\u30b1\u30fc\u30d7<\/li>\r\n    <\/ul>\r\n  <\/li>\r\n  <li>\r\n    <p><b class=\"fw-600\">\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u3092\u5b9f\u88c5\u3059\u308b<\/b><\/p>\r\n    <ul style=\"list-style-type:bullet;\">\r\n      <li><code>is_wp_error()<\/code>\u3067\u30a8\u30e9\u30fc\u30c1\u30a7\u30c3\u30af<\/li>\r\n    <\/ul>\r\n  <\/li>\r\n<\/ol>\r\n<h2 class=\"fz-xl\">\u53c2\u8003\uff1aWordPress\u306e\u6761\u4ef6\u5206\u5c90\u30bf\u30b0<\/h2>\r\n<ul style=\"list-style-type:bullet;\">\r\n  <li><code>is_singular()<\/code> - \u6295\u7a3f\u3001\u56fa\u5b9a\u30da\u30fc\u30b8\u3001\u30ab\u30b9\u30bf\u30e0\u6295\u7a3f\u30bf\u30a4\u30d7\u306e\u500b\u5225\u30da\u30fc\u30b8<\/li>\r\n  <li><code>is_single()<\/code> - \u6295\u7a3f\u306e\u500b\u5225\u30da\u30fc\u30b8<\/li>\r\n  <li><code>is_page()<\/code> - \u56fa\u5b9a\u30da\u30fc\u30b8<\/li>\r\n  <li><code>is_category()<\/code> - \u30ab\u30c6\u30b4\u30ea\u30fc\u30a2\u30fc\u30ab\u30a4\u30d6<\/li>\r\n  <li><code>is_tag()<\/code> - \u30bf\u30b0\u30a2\u30fc\u30ab\u30a4\u30d6<\/li>\r\n  <li><code>is_tax()<\/code> - \u30ab\u30b9\u30bf\u30e0\u30bf\u30af\u30bd\u30ce\u30df\u30fc\u30a2\u30fc\u30ab\u30a4\u30d6<\/li>\r\n  <li><code>is_archive()<\/code> - \u30a2\u30fc\u30ab\u30a4\u30d6\u30da\u30fc\u30b8\u5168\u822c<\/li>\r\n  <li><code>is_home()<\/code> - \u30d6\u30ed\u30b0\u6295\u7a3f\u4e00\u89a7<\/li>\r\n  <li><code>is_front_page()<\/code> - \u30d5\u30ed\u30f3\u30c8\u30da\u30fc\u30b8<\/li>\r\n  <li><code>is_404()<\/code> - 404\u30a8\u30e9\u30fc\u30da\u30fc\u30b8<\/li>\r\n  <li><code>is_search()<\/code> - \u691c\u7d22\u7d50\u679c\u30da\u30fc\u30b8<\/li>\r\n<\/ul>\r\n<p>\u3053\u308c\u3089\u306e\u5b9f\u88c5\u306b\u3088\u308a\u3001\u30a8\u30e9\u30fc\u3092\u56de\u907f\u3057\u306a\u304c\u3089\u3001\u67d4\u8edf\u306a\u30da\u30fc\u30b8\u3054\u3068\u306e\u30c7\u30b6\u30a4\u30f3\u5236\u5fa1\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\r\n\r\n<a href=\"https:\/\/code-plus.jp\/gp\/error-null-9560\/\" class=\"linkbox my-1.5r\">\r\n<h4 class=\"linkbox-title fz-md\">WordPress $post\u5909\u6570\u306enull\u30a8\u30e9\u30fc\u3092\u5b8c\u5168\u89e3\u6c7a\uff01error_log\u3092\u7dba\u9e97\u306b\u3059\u308b\u5b9f\u8df5\u7684\u4fee\u6b63\u30ac\u30a4\u30c9<\/h4>\r\n<picture class=\"linkbox-thumbnail\">\r\n<img decoding=\"async\" width=\"300\" height=\"200\" src=\"https:\/\/code-plus.jp\/gp\/wp-content\/uploads\/709908c76c94361c5aecc71412bcd1c1.jpg\" alt=\"WordPress $post\u5909\u6570\u306enull\u30a8\u30e9\u30fc\u3092\u5b8c\u5168\u89e3\u6c7a\uff01error_log\u3092\u7dba\u9e97\u306b\u3059\u308b\u5b9f\u8df5\u7684\u4fee\u6b63\u30ac\u30a4\u30c9\" loading=\"lazy\" \/>\r\n<\/picture>\r\n<span class=\"linkbox-excerpt\">error_log\u306b\u983b\u51fa\u3059\u308b\u300cAttempt to read property on null\u300d\u30a8\u30e9\u30fc\u3002WordPress \u306e$post\u5909\u6570\u304c\u539f\u56e0\u3067\u3059\u3002\u672c\u8a18\u4e8b\u3067\u306f5\u3064\u306e\u5178\u578b\u30d1\u30bf\u30fc\u30f3\u3068\u4fee\u6b63\u65b9\u6cd5\u3001\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u3067\u306e\u4e00\u5143\u7ba1\u7406\u307e\u3067\u5b9f\u8df5\u7684\u306b\u89e3\u8aac\u3002$post-&gt;ID\u3084$p...\r\n&emsp;<u class=\"linkbox-more\">\u7d9a\u304d\u3092\u8aad\u3080<\/u>\r\n<\/span>\r\n<\/a>","protected":false},"excerpt":{"rendered":"WordPress\u3067<body>\u306bID\u3084\u30af\u30e9\u30b9\u3092\u8ffd\u52a0\u3059\u308b\u65b9\u6cd5\uff1a<body id='<?php echo($post->post_name); ?>'> \u5b9f\u306f\u3053\u306e\u30b3\u30fc\u30c9\u3001\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3059\u3002\u4eca\u56de\u306f\u306a\u305c\u30a8\u30e9\u30fc\u304c\u8d77\u304d\u308b\u306e\u304b\u3001\u305d\u3057\u3066\u3069\u3046\u3059\u308c\u3070\u6b63\u3057\u304f\u5b9f\u88c5\u3067\u304d\u308b\u306e\u304b\u3092\u3001\u521d\u5fc3\u8005\u306e\u65b9\u306b\u3082\u308f\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3057\u307e\u3059\u3002","protected":false},"author":1,"featured_media":8406,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","footnotes":"","vk-ltc-link":"","vk-ltc-target":"0"},"categories":[13],"tags":[153,154,155,130,102,111,112],"group":[],"class_list":["post-8404","post","type-post","status-publish","format-standard","has-post-thumbnail","category-wordpress","tag-body_class","tag-154","tag-functions-php","tag-css","tag-wordpress","tag-php","tag-112"],"acf":[],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/posts\/8404","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/comments?post=8404"}],"version-history":[{"count":0,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/posts\/8404\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/media\/8406"}],"wp:attachment":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/media?parent=8404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/categories?post=8404"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/tags?post=8404"},{"taxonomy":"group","embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/group?post=8404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}