Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Target pages in WordPress?

  • This topic is empty.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #31709
    charlie
    Participant

    How can I target pages with CSS in WordPress. I would like to spec different styles in the index.php, single.php, archive.php etc.

    Those pages don’t have a unique opening body tag.

    #59068
    TheDoc
    Member

    Have you set up your body tag like this:

    >

    Because that will spit out all of the selectors you could need.

    #59069
    charlie
    Participant

    YES!

    How do I get started? I know very little about php.

    #59070
    TheDoc
    Member

    Find your header.php file, that’s where you should have the body tag.

    Simply replace:

    with:

    >

    And check the results on your website.

    #59141
    charlie
    Participant

    Do I have to target the whole class?

    or can I just use archive or single etc.?

    #59059
    TheDoc
    Member

    You can target whichever you like!

    If you want to target the category “marketingbytes”, for example, you could do this in your css:

    .category-marketingbytes #wrapper #content a {
    color: blue; /* Marketing Bytes links will be blue! */
    }
    #59057
    charlie
    Participant

    What about just “archive” or “single?”

    .archive h2 {}
    #59049
    TheDoc
    Member

    That would work fine, too.

    So ‘.archive h2’ would target all h2’s within any archive page.

    single.php is used for posts, page.php is used for pages, etc etc.

    #59018
    charlie
    Participant

    That’s great. Thank you!

Viewing 9 posts - 1 through 9 (of 9 total)
  • The forum ‘CSS’ is closed to new topics and replies.