WordPress.org

Ready to get started?Download WordPress

Forums

Request: CSS body class for top level parent page (4 posts)

  1. Jack
    Member
    Posted 10 months ago #

    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...
    }

  2. esmi
    Forum Moderator
    Posted 10 months ago #

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

  3. Jack
    Member
    Posted 10 months ago #

    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.

    http://www.jacktummers.nl/fotografie

  4. esmi
    Forum Moderator
    Posted 10 months ago #

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

Reply

You must log in to post.

About this Topic

Tags

No tags yet.