WordPress.org

Ready to get started?Download WordPress

Forums

How to style date added with PHP code (3 posts)

  1. irenejanssen
    Member
    Posted 1 year ago #

    Hi guys,

    My blog is http://www.sistersinparadise.nl 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!

    Irene

  2. esmi
    Forum Moderator
    Posted 1 year ago #

    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.

  3. Alison Foxall
    Member
    Posted 1 year ago #

    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>

Topic Closed

This topic has been closed to new replies.

About this Topic