Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2012
    Posts
    19
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Best way to update a nested template-specific class

    I'm working on a WordPress site right now and I want to style post meta data differently on a category archive page as opposed to a single post page. They are both using the entry-date class but the body that is called is different between the archives and single post.

    Here is how the classes and IDs are nested for the archive page:

    Code:
    <body class="archive category category-blog category-11 logged-in admin-bar browser-gecko">
    <div id="page" class="hfeed container">
    <div id="main" class="clearfix">
    <div id"content" class="sidebar" role="main">
    <div class="entry-content">
    <span class="entry-meta">
    <span class="entry-date">
    As comparison, a single post page, everything is the same except the first line:

    Code:
    <body class="single single-post postid-191 single-format-standard logged-in admin-bar browser-gecko">
    In the template's original CSS, there is body.archive, which is what I want to update -- all types of categories (categories, tags, etc.)

    How do I add template-specific CSS so that my entry-date styling only affects the pages using body.archive? I've experimented with different nesting techniques but I'm not having any luck.

    I would link the site but the WP site is hidden to the public until launch. Thanks for your input!

  • #2
    Senior Coder
    Join Date
    Feb 2009
    Location
    Ilkley, West Yorkshire, UK
    Posts
    2,955
    Thanks
    9
    Thanked 726 Times in 720 Posts
    This is straightforward:

    Code:
    body.archive .entry-date{...styles...}
    will do the trick. So this style will only apply to elements with class of entry-date within body elements that have class archive.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •