[resolved] Styling the_date function (7 posts)

  1. elkirkmo
    Posted 3 years ago #

    What I want to do is style every part of the date differently, i.e Thursday, August 2nd, But I'm not sure what the best way to do that is.

    Currently I have: <h2><span class="fancy"><?php the_time('l');?></span></h2><h2><?php the_date('F jS');?></h2>

    I'm mostly interested in making the nd part of 2nd be small and up in the corner of the 2. Does anyone have any advice on this?

  2. Andrew
    Forum moderator
    Posted 3 years ago #

    Can you show the HTML generated for the date?

  3. elkirkmo
    Posted 3 years ago #

    <h2><span class="fancy">Thursday</span></h2><h2>August 2nd</h2>

  4. Andrew
    Forum moderator
    Posted 3 years ago #

    You can select through CSS the two date parts

    h2 span.fancy { ... }


    h2 > span.fancy ~ h2 { ... }

    If you're still struggling to select them, you could add CSS it through jQuery.

  5. Michael
    Forum Moderator
    Posted 3 years ago #

    the time is already broken into two parts; break it into some more parts:


    <span class="fancy"><?php the_time('l');?></span>
    <span class="fancy-month"><?php the_time('F');?></span>
    <span class="fancy-date"><?php the_time('j');?></span>
    <span class="fancy-suffix"><?php the_time('S');?></span>


  6. elkirkmo
    Posted 3 years ago #

    I'll try that, but when I did that before, it'd only display the first the_time and disregard the rest. Maybe I forgot a question mark or something.

  7. elkirkmo
    Posted 3 years ago #

    Hot damn, it worked! Thanks, alchymyth!

Topic Closed

This topic has been closed to new replies.

About this Topic