WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Styling the_date function (7 posts)

  1. elkirkmo
    Member
    Posted 1 year 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 1 year ago #

    Can you show the HTML generated for the date?

  3. elkirkmo
    Member
    Posted 1 year ago #

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

  4. Andrew
    Forum Moderator
    Posted 1 year ago #

    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.

  5. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    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

  6. elkirkmo
    Member
    Posted 1 year 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
    Member
    Posted 1 year ago #

    Hot damn, it worked! Thanks, alchymyth!

Topic Closed

This topic has been closed to new replies.

About this Topic