WordPress.org

Support

Support » Requests and Feedback » Request: CSS body class for top level parent page

Request: CSS body class for top level parent page

  • Now the class range is ‘page page-id-12933 page-child parent-pageid-12932’, but there is no class for a top level page.

    In my case I wanted to give a page and all of it’s sub(sub,sub etc.) pages a different margin and padding. In the example above parent-pageid-12932 is already a childpage of a top level page, but it’s not mentioned in the body classes.

    If it were, I could declare styles for all pages like this:

    body.top-level-page,
    body.top-level-page.page-child {
    styles…
    }

Viewing 3 replies - 1 through 3 (of 3 total)
  • esmi

    @esmi

    Forum Moderator

    Can you post a link to a page demonstrating the problem?

    Well, it’s not really a problem, more something about efficiency.

    On the page below I have blog pages and other pages, and I have a portfolio with photographs, created with the NextGen plugin. For both group of pages I need a different top margin for the sidebar. Now I used a bunch of body classes, like body.page-id, but all that could have been accomplished if I could just have the /fotografie page and all of its children have an different top margin. At this moment that doesn’t sound like a big deal, but soon there will be dozens of pages and sub(sub)pages with photographs.

    Fotografie

    esmi

    @esmi

    Forum Moderator

    Why not create a custom page template for these pages and then use the generated page template class on the body tag?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Request: CSS body class for top level parent page’ is closed to new replies.
Skip to toolbar