Support » Fixing WordPress » Change css single page (only parent)

  • Hello,

    I’m having a problem which I can’t solve. I want to change the background-color of .cat_article on a certain page called ‘store’. ( I was able to do this with the following code:

    <body<?php if ( is_page(‘store’)) {
    echo ‘ class=”myclass” ‘; } ?>>

    .myclass .cat_article {background-color: #000000;}

    However, I only want the background-color to show on /store and not /store/xxxx (all the subpages). How can I fix this? I really hope someone can help me out, because this is really driving me crazy!! Thanks in advance!

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


    Forum Moderator

    Dos your theme use the body_class function? If so, you can use CSS to target your CSS changes at a specific page using the classes generated on the <body> tag.

    Hi Esmi, thanks for your reply.

    I’m not really sure how to use the body class function. I have the following code, but then the CSS does not only apply to the parent page, but also the subpages and that’s not what I want.

    <body<?php if ( is_page(‘store’)) {
    echo ‘ class=”myclass” ‘; } ?>>

    Do you, or anyone else, how to change the code so it only applies to one URL and not the subpages?

    never mind; I’ve changed the lay-out

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Change css single page (only parent)’ is closed to new replies.