Skip to content

Instantly share code, notes, and snippets.

@studiopress
Last active October 27, 2017 00:10
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save studiopress/5706780 to your computer and use it in GitHub Desktop.
Save studiopress/5706780 to your computer and use it in GitHub Desktop.
Genesis body class.
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Add custom body class to the head
add_filter( 'body_class', 'sp_body_class' );
function sp_body_class( $classes ) {
if ( is_category( '1' ) )
$classes[] = 'custom-class';
return $classes;
}
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Add custom body class to the head
add_filter( 'body_class', 'sp_body_class' );
function sp_body_class( $classes ) {
if ( is_category( 'sample-category' ) )
$classes[] = 'custom-class';
return $classes;
}
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Add custom body class to the head
add_filter( 'body_class', 'sp_body_class' );
function sp_body_class( $classes ) {
$classes[] = 'custom-class';
return $classes;
}
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Add custom body class to the head
add_filter( 'body_class', 'sp_body_class' );
function sp_body_class( $classes ) {
if ( is_page( '1' ) )
$classes[] = 'custom-class';
return $classes;
}
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Add custom body class to the head
add_filter( 'body_class', 'sp_body_class' );
function sp_body_class( $classes ) {
if ( is_page( 'sample-page' ) )
$classes[] = 'custom-class';
return $classes;
}
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Add custom body class to the head
add_filter( 'body_class', 'sp_body_class' );
function sp_body_class( $classes ) {
if ( is_tag( '1' ) )
$classes[] = 'custom-class';
return $classes;
}
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Add custom body class
add_filter( 'body_class', 'sp_body_class' );
function sp_body_class( $classes ) {
if ( is_tag( 'sample-tag' ) )
$classes[] = 'custom-class';
return $classes;
}
@marybaum
Copy link

category-sample.php didn't work until I changed the conditional to read
`if (in_category(blah-de-blah ...
return $classes;
}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment