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)?
- How do themes provide support for child themes?
- Is it possible to override the result of get_template_part()?
- Why is the Child Theme Stylesheet Not Loading?
- One Child Functions.php for Multiple Child Themes
- How do I remove specific styles from the parent theme css using the child theme css?
- Do all files in child theme override the parent?
- Change Genesis Tag from Page Template [closed]
- Under heavy cache conditions, updating the parent theme don’t reflect changes with child theme enabled
- Uncaught Error: Call to undefined function get_user_by() after moving function from theme to plugin
- override parent theme configuration in child functions.php
- Loading files for theme and child theme (Require)
- Child Theme Path Being Ignored With wp_enqueue_scripts
- Child theme style repeated
- bbpress change the word forum, topic, reply in the forum to another word I choose
- Should a child theme share the same theme options row as the parent, or should it have it’s own options row?
- Overwriting Parent Theme’s Image Sizes
- What do you put in child themes author tag?
- Confused about how to use wp_enqueue_style
- Order of stylesheets in child theme
- How to first edit in local WordPress editor on page and the add code?
- Buddypress – Add the post_id in the bp_activity_add function
- Adding a title below the logo
- Show the content that is after the excerpt using child theme
- Can´t access child theme´s scripts dependencies found in parent
- Replace part of a parent-theme customizer in the child-theme
- Development of new theme and rollout on multisite
- How to override p2 breathe theme plugin in content template file?
- How to load parent theme template parts in child theme
- add_filter to parent theme helper class function from child theme
- Child theme stylesheet not always overriding “index”
- Running script based on Category
- Load File (Function & Variable Value) from Child Theme
- Child Theme CSS not showing at all
- Why is my child theme style.css not found (404) in the front-end? [closed]
- What’s the default order used by WordPress to load CSS files?
- Why does the Woocommerce grouped template prints the unpublished products?
- Custom shortcode works in Elementor editor but not on frontend
- Trying to add a custom social icon to a Twenty Twenty-One child theme
- Where do I go to edit this area? [closed]
- Remove action in a parent theme from the child theme
- Remove action within a class in a parent theme’s includes folder from the child theme
- Alignment Problem [closed]
- How can I remove all traces of a theme?
- Child theme not importing parent styles
- What $handle does WordPress use for a theme’s implicit style.css?
- Changing CPT slug and taxonomy already registered in parent theme
- Updating WordPress Theme Files
- Overriding Plugin Function in Child Theme
- How to overwrite template.php file
- Function to limit number of custom post types on homepage – TwentyTen
- Switching to child theme breaks menu names
- Can’t seem to get javascript code working from child theme
- Css will not display in webpage, after adding it in style.css in child theme
- Easily add custom HTML outside the main container?
- template_include doesn’t work with child theme
- Remove Stylesheet by URL that has not been enqueued
- How to fix error message to edit sidebar widget text on a livesite childtheme?
- How can i add product Accessories from front-end using custom php form?
- Downloading customized theme from wordpress
- WordPress core jquery version file not loaded?
- How to change the structure/order of sections in a WordPress theme? [closed]
- How to customize a section of a widget only on certain pages or page
- Is it safe to update an old site after backing it up and activating a child theme?
- Child Theme Can’t Find Parent In a Folder
- random woocommerce categories are not showing when count enabled?
- Problems with child theme
- What is the “best” way to update a theme via a plugin?
- CSS in child theme to replace !important in parent theme
- uninstall a theme programmaticlly
- How do I move my sites to a child theme without loosing customisation?
- WordPress Child Theme Template auth_redirect wrapper
- How to allow users to switch to the child theme from front end without plugin?
- Update add_image_size
- How to include only modifications in child theme?
- Child Theme > Template
- Standard Way To Do Custom Work Within A Page?
- how to keep theme background image, menu or site header image while moving site in sub directory?
- Browser stacks different versions of style.css
- Word Press Theme Customiser and Child theme Function.php
- Is there any way to show child theme in theme detectors?
- Unload templates; disable parent Template Parts using only “theme.json”