You could use slugs instead of IDs.
Taken from the Starkers theme (add it to your functions.php):
add_filter( 'body_class', 'add_slug_to_body_class' );
function add_slug_to_body_class( $classes ) {
global $post;
if( is_home() ) {
$key = array_search( 'blog', $classes );
if($key > -1) {
unset( $classes[$key] );
};
} elseif( is_page() ) {
$classes[] = sanitize_html_class( $post->post_name );
} elseif(is_singular()) {
$classes[] = sanitize_html_class( $post->post_name );
};
return $classes;
}
Related Posts:
- JQuery undefined and Stylesheet loads in bottom along with js files
- Ideal inline dynamic CSS injection
- Javascipt issue on custom theme
- Theming Using Bootstrap Glyphicons and WordPress Dashicons
- How to make javascript work on theme options page
- Broken theme, template is missing
- Weirdness in jQuery supplied with WordPress
- Having issue with WordPress wp_enqueue_style
- How do I use wp_nav_menu?
- How can I wrap all blog posts image with
- theme style is applied on the dhasboard rather than the website
- White screen when attaching css to function.php
- Assign custom classes to the divs inside the loop
- SVG in list-style-image breaks when adding fill
- WordPress theme resource won’t load over VPN
- theme-independent CSS/JS files
- How to style bootstrap container in wordpress theme?
- CSS added through customizer neglects the need of a child theme?
- How to override template files in parent theme?
- jQuery from parent theme loaded with many other scripts in a single min.js file
- jQuery accordion menu
- LESS not working in WordPress [closed]
- Place title (in correct place) above image with opaque background [closed]
- A post with a clear:both in its css destroy the theme design, and the sidebar is moved to the bottom
- multiple html/css files for wordpress theme?
- CSS preprocessor file messed up after compiled
- Trouble in enquing all js files under certain directory
- Customize Option Framework
- Why I obtain different visualization when I run the website on my local machine and on remote server?
- Some doubts about WordPress handle the horizontal main menu visualization
- How to create a WP theme that use BootStrap? [closed]
- Can’t change theme name
- my single.php is mixup on some post for no reason
- How do I implement jPanelMenu?
- How to use the _S framework
- header, stylesheet not being read
- Tiny MCE custom styles, and preview in the backend
- How to format the first line of a post differently?
- loading javascript after jquery is loaded
- .current_page_ancestor broken in Twenty Eleven
- MapPress Easy Google Map in Jquery Tabs Problem
- I don’t think WordPress is loading jquery or bootstrap js
- WordPress Animation Adjustments
- Is there a list of default generated Gutenberg block CSS? Unable to align video blocks
- style variations hurt the editing performance
- How to create a robust and logic class naming system in WordPress theme developing?
- Why nav_menu_css_class doesn’t work with apply_filters?
- how can i remove js file from my footer in wordpress
- How do I change the color of individual page titles in WordPress?
- How to properly use AWS SES for a contact form?
- 3 Level Menu Navigation (3rd Level not displaying)
- Default customizer colors aren’t displayed outside of the preview
- Embedding CodePen Calorie Script – jquery error
- Find the source file causing a Mixed Content warning
- How to load jQuery with Ajax in WP version 5.3.2?
- How to enqueue scripts properly with ES6 webpack?
- How to reduce the vertical space above and below a ul list uniformly with one command?
- Infinite scroll without plugin using ajax
- Is there a way to add classes to a page when using a Gutenberg reusable block as page layout?
- change background image on scroll
- How can I fix my theme header for my CSS stylesheet?
- How to display only the first two elements from ten same elements
- WordPress doesn’t load css, image and js files after moving local installation folder
- How to generate a rtl.css file for themes?
- Load multiple css simultaneously using functions.php
- Necessary css classes to be included in theme stylesheet
- overlay post title over post’s featured image
- how to add jquery to wordpress
- Change site title color on individual pages
- Images use & location, on new wordpress theme
- Mobile view logo background colour in wordpress
- How to fix an issue with customizer live preview?
- Activating theme in local MAMP installation results in HTTP ERROR 500
- WordPress Customization API overwrite LESS variable
- jQuery conflict in WordPress, works fine in HTML
- How would I get this to work – send to post from thick box
- Custom CSS no getting applied
- How can I fix the even/odd child classes comments so that the comments are unaffected by the top-level even/odd?
- editor style css and page template with and without sidebar
- Enqueue Stylesheets After Theme’s “rtl.css”
- WordPress 3.5 + Foundation 5 not working on IE9
- FitVid not working for iframes on particular theme install
- Why the slideshow is not shown in my theme?
- Enable WP to accept standard jQuery code embeding between the tags [duplicate]
- WordPress custom jquery not found
- Passing a location-dependent array via wp_localize_script within a shortcode
- Any disadvandages if I style the wordpress align classes without img and .wp-caption prefix
- enqueue script if page is not equal to
- Set start page depending on screen width [closed]
- adding navigation to genesis themes
- Alternating CSS classes for dynamic content [closed]
- Custom link color or stylesheets
- WordPress Subpages Fancybox Trouble
- How to reuse parts of WordPress site e.g. header, footer, part of header for multiple WordPress sites?
- Header is not showing full width
- Saving Permalinks Results in 403 MAMP (Windows)
- Setting different CSS for all pages except home.php
- How do I middle-align my header menu items in WordPress [closed]
- How to resize video lightbox popup in wordpress? [closed]
- How can I get rid of the distance when I’m using list-style-type: none? [closed]