WordPress.org

Ready to get started?Download WordPress

Forums

Change css single page (only parent) (4 posts)

  1. connepon1985
    Member
    Posted 1 year ago #

    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'. (http://www.paardenlifestyle.com/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!

  2. esmi
    Forum Moderator
    Posted 1 year ago #

    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.

  3. connepon1985
    Member
    Posted 1 year ago #

    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?

  4. connepon1985
    Member
    Posted 1 year ago #

    never mind; I've changed the lay-out

Topic Closed

This topic has been closed to new replies.

About this Topic