• somefool

    (@somefool)


    My site outputs the date as (for example) Thursday 3rd June 2004.
    Id like to put <span> </span> around the day of the week so that I can make it a different colour to the rest of the date.
    Is there any way to do this?

Viewing 8 replies - 1 through 8 (of 8 total)
  • oisin

    (@oisin)

    In your index.php file, there is the following line (if you haven’t changed it; this is the out-of-the-box version of index.php):
    <?php the_date('','<h2>','</h2>'); ?>
    That will create the following HTML for you:
    <h2>Saturday 5th June 2004</h2>
    In your style sheet, you can modify the settings for the h2, or you can change the the_date() call in your index.php to add a span that you can modify in your style sheet. To add a span in your index.php, just replace the code above with:
    <?php the_date(",'<h2><span>','</span></h2>'); ?>

    Beel

    (@beel)

    I can’t think of a way without hacking the code.

    Thread Starter somefool

    (@somefool)

    yes, im aware of <span> within <h2> around the date – just not on a specific portion of the date – maybe some enterprising WP plugin writer would be kind enough 😉
    i did have a look at the the_date function, but i couldnt see how to alter it.

    Beel

    (@beel)

    I suspect you would have to write something to filter the date through – a bit much I would think.

    Thread Starter somefool

    (@somefool)

    oh well.

    Nick Momrik

    (@mtdewvirus)

    Do you still want the date to only appear once for each day? If you don’t mind it appearing for each post, you could use the_time instead, calling it twice each time. Once for the day of the week which you could style and then once for the rest of the date.
    http://wiki.ww.wp.xz.cn/the_time
    http://wiki.ww.wp.xz.cn/the_date

    Anonymous

    yeah, separate calls are the way to go. just feed the relevant parameters into the function calls as per the wiki.

    Nick Momrik

    (@mtdewvirus)

    Good idea Oisin…I never thought of passing the “span” through to the_date function. Pretty slick!

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘the_date formating with <span>’ is closed to new replies.