@Oren, I’m not understanding the question. There’s nothing wrong with adding a class of “page-parent” if you want to. This shows you how to add a custom class to the body element. If you mean in reference to the class “parent-pagename-NAME-OF-PARENT” added by this function, it’s in keeping with WP’s naming convention. The core file adds a class of “parent-pageid-ID-OF-PARENT“, this just mimics that with a name instead of a number.

Just learning about the body_class function and this has been a great help – your tutorials are some of the best I have read and are always very well presented in a great step by step format … thank you for sharing

Nice tutorial, unlike Dave it only took me 10 minutes to find this article. Google search is an acquired skill. I just needed to find out how to tap into the body_class() so I can use different css tags for header images on pages. Obviously you can’t use categories or tags on pages, well actually you can, but that would take a different coding solution and I don’t want to go in that direction. I will use post meta to create radio buttons on my clients page editor. That way they can choose if they want the header background to focus on the vertical center of the image, more towards the top, or more towards the lower part of the image of their responsive header background which is overflow: hidden of the header-img div. The header-img div height is fixed so the aspect ratio changes and therefore the image has to be taller than the div but the vertical center has to adjust depending on the screen size.


Comments are closed.