You’re probably looking for something like this:
<?php
function add_classes_to_body_class($classes) {
// make sure 'page-template.php' matches your template name
if ( is_page_template('page-template.php') ) {
$classes[] = 'main';
}
return $classes;
}
add_filter( 'body_class', 'add_classes_to_body_class' );
?>
make sure you add body_class()
into your markup. Traditionally it would be in your body tag like so. <body id="foobar" <?php body_class(); ?>>
Related Posts:
- How to replace the twentyten image header with my flash banner?
- How to disable commenting from Twenty Ten theme? [closed]
- How to override function in functions.php of parent theme?
- Can I sell a theme based off of TwentyTen
- How to create a drop down menu like in twenty eleven theme?
- Remove “Posted on” and “Posted in” from the Twenty Ten Theme
- Customized widget area – how to override or filter class xoxo?
- How do I create a magazine type menu – sub-menu setup using wp_nav_menu and child of twentyten? [closed]
- Twenty Ten child theme has post on an inner page. Cant get that page to use my desired template
- update = remove code
- I would like to remove the url and description from about the header
- Remove Header from specific page in Twenty Ten [closed]
- Where is the code that set the background image in TwentyTen theme?
- Twenty ten or Twenty eleven as base for responsive child theme
- Best way to add some custom javascript using jquery to a child theme
- Remove Author, Post and Category-related Text from a Theme?
- Adding Tag On Single Post from bbpress (Tewenty Ten) Themes
- Making a 1140px wide header logo in the twenty-ten theme?
- How to get twenty ten content side by side (images and/or text)?
- get_template_directory_uri pointing to parent theme not child theme
- How to customize the_archive_title()?
- Opinions and recommendations on the best barebones base theme [closed]
- How to override JavaScript files in child theme?
- How do I dequeue a parent theme’s CSS file?
- How to override parent functions in child themes?
- Versioning @import of parent theme’s style.css
- How to add code to Header.php in a child theme?
- Why does my child theme CSS get called twice?
- remove_action on after_setup_theme not working from child theme
- Remove parent theme action in child
- How to *remove* a parent theme page template from a child theme?
- WooCommerce: change display order of product short description and price [closed]
- How do I make my child theme re-apply the settings that were customised when its parent was active?
- How to properly dequeue scripts and styles in child theme?
- How do themes provide support for child themes?
- How to move the sidebar in TwentyFifteen to the right?
- Attributing a version number to a child theme’s main stylesheet
- Preserving theme settings in child theme
- Is it possible to make grandchild themes?
- how can I add an icon/image for a child theme?
- how do I queue my Child stylesheet/s *after* every Parent stylesheet/statement?
- Override parent theme translation on child theme
- Adding a second email address to a completed order in WooCommerce [closed]
- How to cache bust a child theme style.css
- Override get_template_directory() in child theme?
- Child themes CSS priority problems without using !important
- Is it possible to override the result of get_template_part()?
- Childs PHP files not overwriting Parent’s PHP files
- Starter Theme vs Parent Theme? Pros and cons
- Child theme – Overriding ‘require_once’ in functions.php
- WooCommerce shop page to use my custom template [closed]
- Overriding Plugin Template Files with Child Theme
- How to set thumbnail image for a (child) theme
- Adding javascript to child theme
- Is a text-domain necessary for a child theme
- How to modify single.php in a child theme?
- Cannot get Child Theme to load latest version of style.css
- Issues enqueueing parent & child theme stylesheets with revised Codex method
- Include files in child theme functions file
- How do I cleanly override a plugin’s CSS with a child theme?
- @package & @subpackage: how to use with child themes
- How to override function in child theme
- My child theme doesn’t work Error: “The parent theme is missing. Please install your parent theme”
- Redeclare a function in a child theme
- Why is the Child Theme Stylesheet Not Loading?
- Do Child-Themes automatically load the Translation from the Parent-Theme?
- Hiding Parent Theme
- Child Theme vs Duplicate Theme Renamed
- How do I change the login logo URL and hover title?
- WordPress Multisite Multiple child theme
- get_stylesheet_directory() vs get_template_directory() for child theme
- How to override a function when isn’t at functions.php
- Theme Customization API and child themes
- why is translation not working on theme?
- Hide a div that is part of all pages on one specific page
- Child theme functions.php do I use php open and close tags?
- Difference between stylesheet_directory and template_directory
- How to override the “inc” folder (or any folder) in a theme using child theme?
- Declaring an instance of class included in parent theme from child theme functions.php
- get_parent_theme_file_path vs. get_template_directory
- How to Add Customizer Setting in Child Theme
- Git vs Child Theme
- How to add Color Picker in Theme Options for the following?
- One Child Functions.php for Multiple Child Themes
- Give priority to child theme stylesheet
- Child theme does not overwrite parent themes style.css
- how to call files in child theme?
- Get Parent Theme Author Name
- Is it possible to disable a function of a parent theme?
- Adding Action Hooks In Parent Theme For Easier Child Theme Customization
- Removing custom background and header feature in child theme
- How to override an unpluggable parent theme function?
- Change slug of registered custom post type in child theme
- Adding post-formats to Twenty Ten child theme
- Get parent theme version
- Assign Menus to Theme Locations with theme activation
- Optimal approach for replacing the 8 header images in a child theme?
- Hiding a theme’s meta box
- Jquery in Child Theme
- jquery script not enqueued in child theme