{"id":10098,"date":"2014-11-27T23:21:31","date_gmt":"2014-11-27T17:21:31","guid":{"rendered":"http:\/\/devstech.com\/?p=10098"},"modified":"2026-02-08T03:29:26","modified_gmt":"2026-02-07T21:29:26","slug":"add-custom-body-class-genesis","status":"publish","type":"post","link":"https:\/\/www.usefulblogging.com\/add-custom-body-class-genesis\/","title":{"rendered":"How to Add Custom Body Class in Genesis Theme?"},"content":{"rendered":"\n<p>Genesis Framework : In this tutorial, you\u2019ll learn how to <em>Add Custom Body Class in Genesis<\/em>. The Genesis Framework empowers you to quickly and easily build incredible websites with WordPress. Whether you\u2019re a novice or advanced developer, Genesis provides the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go.&nbsp;In Genesis powered websites you&#8217;ve to modify the child theme which is running on.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>These code snippets will help you&nbsp;to&nbsp;Add Custom Body Class with the Genesis Framework.<span id=\"more-10095\"><\/span><span id=\"more-10093\"><\/span><span id=\"more-10091\"><\/span><span id=\"more-9949\"><\/span><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Unless otherwise indicated, the code snippets you see below should be placed into your theme\u2019s functions.php file.<\/p><\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">Add Custom Body Class in Genesis<\/h2>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>Add body class to all pages on your site:<\/strong><br><code><!--?php <br ?--> \/\/* Do NOT include the opening php tag<br>\n\/\/* Add custom body class to the head<br>\nadd_filter( 'body_class', 'sp_body_class' );<br>\nfunction sp_body_class( $classes ) {<br>\n$classes[] = 'custom-class';<br>\nreturn $classes;<br>\n} <\/code><\/p>\n\n\n\n<p><strong>Add body class to a page with a slug of \u2018sample-page&#8217;:<\/strong><br><code><!--?php <br ?--> \/\/* Do NOT include the opening php tag<br>\n\/\/* Add custom body class to the head<br>\nadd_filter( 'body_class', 'sp_body_class' );<br>\nfunction sp_body_class( $classes ) {<br>\nif ( is_page( 'sample-page' ) )<br>\n$classes[] = 'custom-class';<br>\nreturn $classes;<br>\n}<\/code><\/p>\n\n\n\n<p><strong>Add body class to a page with an ID of 1:<\/strong><br><code><!--?php <br ?--> \/\/* Do NOT include the opening php tag<br>\n\/\/* Add custom body class to the head<br>\nadd_filter( 'body_class', 'sp_body_class' );<br>\nfunction sp_body_class( $classes ) {<br>\nif ( is_page( '1' ) )<br>\n$classes[] = 'custom-class';<br>\nreturn $classes;<br>\n}<\/code><\/p>\n\n\n\n<p><strong>Add body class to a category page with a slug of \u2018sample-category&#8217;:<\/strong><br><code><!--?php <br ?--> \/\/* Do NOT include the opening php tag<br>\n\/\/* Add custom body class to the head<br>\nadd_filter( 'body_class', 'sp_body_class' );<br>\nfunction sp_body_class( $classes ) {<br>\nif ( is_category( 'sample-category' ) )<br>\n$classes[] = 'custom-class';<br>\nreturn $classes;<br>\n} <\/code><\/p>\n\n\n\n<p><strong>Add body class to a category page with an ID of 1:<\/strong><br><code><!--?php <br ?--> \/\/* Do NOT include the opening php tag<br>\n\/\/* Add custom body class to the head<br>\nadd_filter( 'body_class', 'sp_body_class' );<br>\nfunction sp_body_class( $classes ) {<br>\nif ( is_category( '1' ) )<br>\n$classes[] = 'custom-class';<br>\nreturn $classes;<br>\n}<\/code><\/p>\n\n\n\n<p><strong>Add body class to a tag page with a slug of \u2018sample-tag&#8217;:<\/strong><br><code><!--?php <br ?--> \/\/* Do NOT include the opening php tag<br>\n\/\/* Add custom body class to the head<br>\nadd_filter( 'body_class', 'sp_body_class' );<br>\nfunction sp_body_class( $classes ) {<br>\nif ( is_tag( 'sample-tag' ) )<br>\n$classes[] = 'custom-class';<br>\nreturn $classes;<br>\n} <\/code><\/p>\n\n\n\n<p><strong>Add body class to a tag page with an ID of 1:<\/strong><br><code><!--?php <br ?--> \/\/* Do NOT include the opening php tag<br>\n\/\/* Add custom body class to the head<br>\nadd_filter( 'body_class', 'sp_body_class' );<br>\nfunction sp_body_class( $classes ) {<br>\nif ( is_tag( '1' ) )<br>\n$classes[] = 'custom-class';<br>\nreturn $classes;<br>\n}<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Final Words<\/h2>\n\n\n\n<p>I strongly recommended to take <strong>backup core files<\/strong> before customizing any Genesis Child Theme. Hope the above Genesis Tutorial was helpful and valued for you. Please don&#8217;t forget to share this with social friends and write a comment below if you need any assistance in customizing the look of your WordPress websites.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Genesis Framework : In this tutorial, you\u2019ll learn how to Add Custom Body Class in Genesis. The Genesis Framework empowers &#8230; <a title=\"How to Add Custom Body Class in Genesis Theme?\" class=\"read-more\" href=\"https:\/\/www.usefulblogging.com\/add-custom-body-class-genesis\/\" aria-label=\"Read more about How to Add Custom Body Class in Genesis Theme?\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":31108,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[568,122],"class_list":["post-10098","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-genesis-framework","tag-code-snippets","tag-genesis","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33","no-featured-image-padding"],"_links":{"self":[{"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/posts\/10098","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/comments?post=10098"}],"version-history":[{"count":1,"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/posts\/10098\/revisions"}],"predecessor-version":[{"id":86567,"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/posts\/10098\/revisions\/86567"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/media\/31108"}],"wp:attachment":[{"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/media?parent=10098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/categories?post=10098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/tags?post=10098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}