{"id":9103,"date":"2024-01-17T17:01:40","date_gmt":"2024-01-17T08:01:40","guid":{"rendered":"https:\/\/colors-themes.com\/clock\/?p=9103"},"modified":"2026-01-17T16:38:13","modified_gmt":"2026-01-17T07:38:13","slug":"if-else","status":"publish","type":"post","link":"https:\/\/colors-themes.com\/clock\/if-else\/","title":{"rendered":"WordPress\u306e\u6761\u4ef6\u5206\u5c90\u306b\u3064\u3044\u3066"},"content":{"rendered":"\n<h1 class=\"wp-block-clock-blocks-block-08 heading-bg title-theme title-style3 title-bg-left\"><span class=\"clock-blocks-align-none\">WordPress\u306e\u6761\u4ef6\u5206\u5c90\u306b\u3064\u3044\u3066<\/span><\/h1>\n\n\n\n<p>WordPress\u306e\u6761\u4ef6\u5206\u5c90\u306e\u30e1\u30e2\u3067\u3059\u3002<br><a href=\"https:\/\/ja.wordpress.org\/team\/handbook\/theme-development\/basics\/template-hierarchy\/\">\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u968e\u5c64<\/a> \u306e\u5916\u89b3\u56f3\u3092\u53c2\u8003\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>if ( is_front_page() &amp;&amp; is_home() ) {\n\t\/\/ \u6295\u7a3f\u4e00\u89a7\u30da\u30fc\u30b8\u3092\u30c8\u30c3\u30d7\u30da\u30fc\u30b8\u306b\u8a2d\u5b9a\n} elseif ( is_home() ) {\n\t\/\/ \u6295\u7a3f\u4e00\u89a7\u30da\u30fc\u30b8\n} elseif ( is_page() ) {\n\tif ( class_exists( 'WooCommerce' ) &amp;&amp; is_cart() ) {\n\t\t\/\/ WooCommerce\u306e\u30ab\u30fc\u30c8\u30da\u30fc\u30b8\n\t} elseif ( class_exists( 'WooCommerce' ) &amp;&amp; is_checkout() ) {\n\t\t\/\/ WooCommerce\u306e\u652f\u6255\u3044\u30da\u30fc\u30b8\n\t} elseif ( class_exists( 'WooCommerce' ) &amp;&amp; is_account_page() ) {\n\t\t\/\/ WooCommerce\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u30da\u30fc\u30b8\n\t} else {\n\t\t\/\/ \u305d\u306e\u4ed6\u306e\u56fa\u5b9a\u30da\u30fc\u30b8\n\t}\n} elseif ( is_single() ) {\n\tif ( 'post' === get_post_type() ) {\n\t\t\/\/ \u30b7\u30f3\u30b0\u30eb\u30da\u30fc\u30b8\n\t} elseif ( 'post' !== get_post_type() ) {\n\t\tif ( is_woocommerce() ) {\n\t\t\tif ( class_exists( 'WooCommerce' ) &amp;&amp; is_product() ) {\n\t\t\t\t\/\/ WooCommerce\u306e\u500b\u5225\u5546\u54c1\u30da\u30fc\u30b8\n\t\t\t}\n\t\t} else {\n\t\t\t\/\/ \u305d\u306e\u4ed6\u306e\u30ab\u30b9\u30bf\u30e0\u6295\u7a3f\u30bf\u30a4\u30d7\u306e\u30b7\u30f3\u30b0\u30eb\u30da\u30fc\u30b8\n\t\t}\n\t} else {\n\t\t\/\/ \u305d\u308c\u4ee5\u5916\u306e\u30b7\u30f3\u30b0\u30eb\u30da\u30fc\u30b8\n\t}\n} elseif ( is_archive() ) {\n\tif ( is_post_type_archive() ) {\n\t\t\/\/ \u30ab\u30b9\u30bf\u30e0\u6295\u7a3f\u30bf\u30a4\u30d7\u540d\u306e\u30a2\u30fc\u30ab\u30a4\u30d6\u30da\u30fc\u30b8\n\t} elseif ( 'post' === get_post_type() ) {\n\t\tif ( is_category() ) {\n\t\t\t\/\/ \u30ab\u30c6\u30b4\u30ea\u30fc\u30da\u30fc\u30b8\n\t\t} elseif ( is_tag() ) {\n\t\t\t\/\/ \u30bf\u30b0\u30da\u30fc\u30b8\n\t\t} elseif ( is_date() ) {\n\t\t\t\/\/ \u65e5\u4ed8\u30da\u30fc\u30b8\n\t\t} elseif ( is_author() ) {\n\t\t\t\/\/ \u8457\u4f5c\u8005\u30da\u30fc\u30b8\n\t\t} else {\n\t\t\t\/\/ \u305d\u306e\u4ed6\u306e\u6295\u7a3f\u30da\u30fc\u30b8\u306e\u30a2\u30fc\u30ab\u30a4\u30d6\u30da\u30fc\u30b8\n\t\t}\n\t} elseif ( 'post' !== get_post_type() ) {\n\t\tif ( is_woocommerce() ) {\n\t\t\tif ( class_exists( 'WooCommerce' ) &amp;&amp; is_shop() ) {\n\t\t\t\t\/\/ WooCommerce\u306e\u5546\u54c1\u4e00\u89a7\u30da\u30fc\u30b8\n\t\t\t} elseif ( class_exists( 'WooCommerce' ) &amp;&amp; is_product_category() ) {\n\t\t\t\t\/\/ WooCommerce\u306e\u30ab\u30c6\u30b4\u30ea\u30da\u30fc\u30b8\n\t\t\t} elseif ( class_exists( 'WooCommerce' ) &amp;&amp; is_product_tag() ) {\n\t\t\t\t\/\/ WooCommerce\u306e\u30bf\u30b0\u30da\u30fc\u30b8\n\t\t\t} else {\n\t\t\t\t\/\/ WooCommerce\u306e\u305d\u306e\u4ed6\u306e\u30da\u30fc\u30b8\n\t\t\t}\n\t\t} elseif ( is_tax() ) {\n\t\t\t\/\/ \u30ab\u30b9\u30bf\u30e0\u6295\u7a3f\u30bf\u30a4\u30d7\u306e\u30ab\u30b9\u30bf\u30e0\u30bf\u30af\u30bd\u30ce\u30df\u30fc\u30da\u30fc\u30b8\n\t\t} else {\n\t\t\t\/\/ \u305d\u306e\u4ed6\u306e\u30ab\u30b9\u30bf\u30e0\u6295\u7a3f\u30bf\u30a4\u30d7\u306e\u30a2\u30fc\u30ab\u30a4\u30d6\u30da\u30fc\u30b8\n\t\t}\n\t} else {\n\t\t\/\/ \u305d\u308c\u4ee5\u5916\u306e\u30a2\u30fc\u30ab\u30a4\u30d6\u30da\u30fc\u30b8\n\t}\n} elseif ( is_search() ) {\n\t\/\/ \u691c\u7d22\u7d50\u679c\u30da\u30fc\u30b8\n} elseif ( is_404() ) {\n\t\/\/ 404\u30da\u30fc\u30b8\n} else {\n\t\/\/ \u305d\u308c\u4ee5\u5916\u306e\u30da\u30fc\u30b8\n}<\/code><\/pre>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h1 class=\"wp-block-clock-blocks-block-08 heading-bg title-theme title-style3 title-bg-left\"><span class=\"clock-blocks-align-none\">WooCommerce\u306e\u6761\u4ef6\u5206\u5c90\u306b\u3064\u3044\u3066<\/span><\/h1>\n\n\n\n<p>WooCommerce\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u6761\u4ef6\u5206\u5c90\u306e\u30e1\u30e2\u3067\u3059\u3002<\/p>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>if ( is_woocommerce() ) {\n\tif ( is_shop() ) {\n\t\t\/\/ WooCommerce\u306e\u5546\u54c1\u4e00\u89a7\u30da\u30fc\u30b8\n\t} elseif ( is_product_category() ) {\n\t\t\/\/ WooCommerce\u306e\u30ab\u30c6\u30b4\u30ea\u30da\u30fc\u30b8\n\t} elseif ( is_product_tag() ) {\n\t\t\/\/ WooCommerce\u306e\u30bf\u30b0\u30da\u30fc\u30b8\n\t} elseif ( is_product() ) {\n\t\t\/\/ WooCommerce\u306e\u500b\u5225\u5546\u54c1\u30da\u30fc\u30b8\n\t} else {\n\t\t\/\/ WooCommerce\u306e\u305d\u306e\u4ed6\u306e\u30da\u30fc\u30b8\n\t}\n} else {\n\tif ( is_cart() ) {\n\t\t\/\/ \u30ab\u30fc\u30c8\u30da\u30fc\u30b8\n\t} elseif ( is_checkout() ) {\n\t\t\/\/ \u652f\u6255\u3044\u30da\u30fc\u30b8\n\t} elseif ( is_account_page() ) {\n\t\t\/\/ \u30a2\u30ab\u30a6\u30f3\u30c8\u30da\u30fc\u30b8\n\t} else {\n\t\t\/\/ \u305d\u306e\u4ed6\u306e\u30da\u30fc\u30b8\n\t}\n}<\/code><\/pre>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>WordPress\u306e\u6761\u4ef6\u5206\u5c90\u306e\u30e1\u30e2\u3067\u3059\u3002\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u968e\u5c64 \u306e\u5916\u89b3\u56f3\u3092\u53c2\u8003\u306b\u3057\u3066\u3044\u307e\u3059\u3002 WooCommerce\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u6761\u4ef6\u5206\u5c90\u306e\u30e1\u30e2\u3067\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":7923,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[150],"tags":[],"class_list":["post-9103","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-create-theme"],"_links":{"self":[{"href":"https:\/\/colors-themes.com\/clock\/wp-json\/wp\/v2\/posts\/9103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/colors-themes.com\/clock\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/colors-themes.com\/clock\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/colors-themes.com\/clock\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/colors-themes.com\/clock\/wp-json\/wp\/v2\/comments?post=9103"}],"version-history":[{"count":29,"href":"https:\/\/colors-themes.com\/clock\/wp-json\/wp\/v2\/posts\/9103\/revisions"}],"predecessor-version":[{"id":13938,"href":"https:\/\/colors-themes.com\/clock\/wp-json\/wp\/v2\/posts\/9103\/revisions\/13938"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/colors-themes.com\/clock\/wp-json\/wp\/v2\/media\/7923"}],"wp:attachment":[{"href":"https:\/\/colors-themes.com\/clock\/wp-json\/wp\/v2\/media?parent=9103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/colors-themes.com\/clock\/wp-json\/wp\/v2\/categories?post=9103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/colors-themes.com\/clock\/wp-json\/wp\/v2\/tags?post=9103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}