Reputation: 49
I'm trying something i would've thought to be quite simple but has turned out to be much more difficult than i thought. I'm simply trying to apply the following css to a specific page, but i see no way of targeting the html for a specific page without affecting the entire site.
CSS
html {overflow-y: hidden;}
I'm using wordpress and i've found no way to add a class (or an ID) to the html of the page.
Can anyone help me with a solution to my problem?
Thanks
Upvotes: 0
Views: 626
Reputation: 1241
Add the following PHP into your functions.php
file to add the URL of your page in the body class. Then you can use body.page-xxxxx
to target specific pages or posts with CSS.
<?php
//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' );
?>
Upvotes: 1