Support » Themes and Templates » Styling the_date function

  • Resolved elkirkmo

    (@elkirkmo)


    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?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator Andrew Nevins

    (@anevins)

    Forum moderator

    Can you show the HTML generated for the date?

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

    Moderator Andrew Nevins

    (@anevins)

    Forum moderator

    You can select through CSS the two date parts
    e.g

    h2 span.fancy { ... }

    and

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

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

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

    example:

    <h2>
    <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>
    </h2>

    http://codex.wordpress.org/Formatting_Date_and_Time

    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.

    Hot damn, it worked! Thanks, alchymyth!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Styling the_date function’ is closed to new replies.