A common method to target elements of a particular static Page is by its ID like this: .page-id-2 Wouldn’t it be handy if you could instead use the slug of the Page like this? .page-about Adding the following in child theme’s functions.php will automatically add a page-slug class to the body element for all static […]
body_class
How to apply body class in WordPress conditionally for a Page and all its sub Pages
In the members-only forum a user asked: I want to style the h1.entry-title differently for each parent/child page. So About page, and all its sub pages would have a class .blue-bg, Events Page would have .green-bg, etc., with css as below. I have tried using is(tree) code with conditional body_class but it is not working. […]
How to add ‘inner’ body class to all inner pages in WordPress
WordPress automatically adds ‘home’ class to ‘body’ element for the site’s homepage/front page. Wouldn’t it be handier to have a ‘inner’ body class for all the other pages? This can be done by adding the following in child theme’s functions.php:
Recent Comments