there is a filter for that and it’s called… body_class
😉
This should work for your case:
function add_my_custom_body_class( $classes ) {
if ( is_page_template( 'page-customer.php' ) ) {
$classes[] = 'body_customer';
}
return $classes;
}
add_filter( 'body_class', 'add_my_custom_body_class', 10, 1 );
if you wanna add class based on page ID (as you’ve mentioned in comments), you can change the logic inside the function and add class only when particular page is queried, let’s say your page ID is 3:
if ( 3 === get_the_ID() ){
$classes[] = 'your_additional_class';
}
Related Posts:
- Populate editor with some content of a page with a page template
- Getting only direct child pages in WordPress with get_pages
- How to add a .php file to WordPress
- Multiple is_page() in page.php
- Check if a menu is empty?
- class=”parent” for wp_list_pages?
- add_rewrite_rule with bottom priority doesn’t handle the WordPress pages
- Listing all sub-pages?
- Help with a custom page template – listing contents of childpages?
- page template for attachement page?
- syntax issue on php 7.4
- How do I publish only one page to production after making changes on staging?
- Custom Template 404 for specific custom post type
- Can’t load WP function into external function
- Can’t get page content in WordPress
- Way to querry data (tags) from a wordpress database?
- Showing content from one page on another
- Page Automatically Generated from Theme?
- How to hide all child pages with post_query?
- Create Page To Count Comments For Each Post In WordPress Site
- Use .php file as page instead of wordpress page & template file?
- Use WordPress function in php file
- Adding wrapper elements in the_date() like in the_title()?
- Show meta box only for default page template
- How to use theme function in post/page?
- page-slug.php not working but only for specific slug
- Need php code’s output to display underneath a Divi Module
- PHP Output also in Child theme, but different
- How to Display a List of Child Pages For a Parent Page in WordPress
- Display additional page templates and a sidebar on plugin activation
- How do I add my PHP app to a WordPress page whilst keeping semantic URLs?
- A function to get the content of a page
- Contain multiple page templates in one PHP custom template file in WordPress?
- Getting page / post URL on publish and / or update
- remove_action() not working in page template – Genesis
- Calling PHP function doesn’t work in index.php
- Create a custom theme-specific page, invisible in the admin-panel?
- Execute php in pages
- Why isn’t my link attribute getting my css?
- Display custom meta box in my template file
- How to return a Boolean for a page that is a subpage thru its name?
- Loop on a wordpress Page instead of content coming from the WP text editor
- WordPress post-template null warnings
- How to call custom function outside from the admin page?
- making php value numeric
- Strip from or something better?
- Add a select-option to the default widgets
- Defining multiple categories for showing latest posts
- the_post_thumbnail issues
- Is there a way to create a “copy post” link?
- Some problems calling a function into sprintf() inside functions.php template file [closed]
- Dynamic Menu drops pages?
- Adding a ‘style=’ bit to image_send_to_editor output
- Post Views Code Hacks
- Closing WP_LINK_PAGES DIV ID w/After Argmuent
- Aspx/Rss feed – failed to open stream: Redirection limit reached
- Adding an Unlinked Space in a Custom Function
- exclude custom post type from running a function
- Taxonomy term description with style, only if the description exists?
- Exclude function from running on a certain page
- Convert all uploaded PNG files to PNG-8 format
- AJAX function not working [closed]
- Migrating site, only header shows
- Customize field names in backend profile edit page through function.php [duplicate]
- Make table disappear when fields are left blank?
- Menu not styling. New menus functionality giving me a headache
- Get date function not working
- Pagination Not Working (pages duplicating content)
- Use of antispambot with $curauth->email
- Auto create Nextgen Gallery on post creation [closed]
- Uses for function: wp_update_user
- Page load timer?
- How do I call an external php non WordPress class into functions.php?
- Insert content into head tag with function
- Function to call either single post or category
- Custom functions for string data calculations
- How are these PHP functions applied to a specific page in WordPress?
- WP insert post Redirect after function has executed
- SQL error with custom query
- The additional fee for the COD payment method not visible in the front-end
- Hide media for non logged in users
- Programmatically revert to backup .htaccess a possibility?
- PHP identify duplicate words in a text string against a list of words
- How to access all meta data for RSS feed?
- Why Is Number of views on wordpress single post wrong?
- Restrict post to current user in postmeta
- send popup after wp_redirect()
- Remove role of user after X days
- Execute PHP code only with specific user role
- Change Language Title Pagination on Subdomain non Multisite
- remove specificly the last tag in all posts
- User filter posts by year
- How to Redirect Buddypress Directories To Login Page For Non Logged in Users
- How to set value selected using select2 jquery plugin
- bp-custom.php is not working on a WordPress multisite environment. how to fix it?
- Woocommerce order status payment
- Why wp_remote_get() fetches certain web pages while it doesn’t work for my localhost?
- WP Container Displaying Only on First Page of Archive
- Getting text from custom field from customizer
- Workaround for og:image unsupported webp image type, Yoast SEO?