How to Add Page Name or Slug class in Body tag.
You can add page name class or slug name class on every page. so that you can change design according to pages.
1 2 3 4 5 6 7 8 9 |
//Page Slug Body Class function add_slug_body_class( $classes ) { global $post; if ( isset( $post ) ) { $classes[] = $post->post_type . '-' . $post->post_name; } return $classes; } add_filter( 'body_class', 'add_slug_body_class' ); |
Now you will start seeing a new body class being outputted like this: page-{slug}. Use that class to override your default styles and customize elements for specific pages.
[paypal-donation]