Skip to content

Instantly share code, notes, and snippets.

@beastaugh
Created January 10, 2009 00:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beastaugh/45330 to your computer and use it in GitHub Desktop.
Save beastaugh/45330 to your computer and use it in GitHub Desktop.
Add a class of 'page' to the body element on WordPress pages.
<?php
/*
Plugin Name: Classy Pages
Plugin URI: http://tarskitheme.com/
Description: Add a class of <code>page</code> to the <code>body</code> element on pages.
Author: Benedict Eastaugh
Version: 1.0
Author URI: http://extralogical.net/
*/
/**
* Adds a class of 'page' to the body element when on a page, and a class of
* 'single' when on a single post page.
*
* @param array $classes
* @return array $classes
*/
function add_page_class_to_body($classes) {
if (is_page()) $classes[] = 'page';
if (is_single()) $classes[] = 'single';
return $classes;
}
add_filter('tarski_bodyclass', 'add_page_class_to_body');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment