Support » Themes and Templates » How to style date added with PHP code

  • Hi guys,

    My blog is and I’m using the Twenty Twelve theme.

    I wanted the date to show above each post, so I added the PHP code <?php the_time(‘jS F Y’) ?>

    I placed it in content.php and right now it looks like this:

    <header class="entry-header">
    			<?php the_time('jS F Y') ?><br />
    			<?php the_post_thumbnail(); ?>
    			<?php if ( is_single() ) : ?>
    			<h1 class="entry-title"><?php the_title(); ?></h1>
    			<?php else : ?>

    So right now the date shows right above the title, which I wanted, but now I would like to style it (change font, size, colour, etc.). I tried to do that in CSS with the code .date , but it didn’t work.

    Does someone know how I can style the date I added above each post? Do I do this in CSS, if yes, with what code? Thanks so much for your help!


Viewing 2 replies - 1 through 2 (of 2 total)
  • Do not edit the Twenty Twelve theme. It is the default WordPress theme and having access to an unedited version of the theme is vital when dealing with a range of site issues. First create a child theme for your changes. Or use a custom CSS plugin.

    After you create a child theme as esmi mentioned (hugely important, otherwise your changes will be blasted with the next upgrade), you can wrap a span that has a class around the_time, like so:

    <span class="date"><?php the_time('jS F Y') ?></span>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to style date added with PHP code’ is closed to new replies.