Support » Fixing WordPress » Make all pages show current date

  • Resolved sagdude2002

    (@sagdude2002)


    Hi,
    I have a small website with only 3 pages. How can I make all pages show the current date all the time without having to go in and update the pages every day? Thank you.
    Mike

    http://www.MikeBradbury.net

Viewing 6 replies - 1 through 6 (of 6 total)
  • esmi

    (@esmi)

    Forum Moderator

    <?php echo date(‘F j, Y’); ?>`

    http://uk2.php.net/manual/en/function.date.php

    sagdude2002

    (@sagdude2002)

    Hi – thanks for your quick response. Where in the code should I paste this? Here is the date code on the Stylesheet (style.css). Thank you very much.

    .post .date {
    float: right;
    margin:5px 0 0 5px;
    padding:0 10px;
    text-align:center;
    font-size: 0.8em;
    border:#000000 1px solid;
    font-weight:bold;
    background:url(img/vino.gif) no-repeat;
    color:#556677;
    font-family: “Lucida Sans”, “Trebuchet MS”, Verdana, Arial, Serif;
    }
    .post .date span
    {
    display:block;
    }
    .post .date .day
    {
    font-size:1.6em;
    }

    esmi

    (@esmi)

    Forum Moderator

    The date isn’t added to the stylesheet. it’s added to the theme templates.

    sagdude2002

    (@sagdude2002)

    OK, below is the code for the page template (page.php). I want to make sure the month, day and year stack on top of eachother as they are now. I inserted <?php echo date(‘F j, Y’); ?> but that doesn’t stack like it is now. Do you know how I can put the code in to keep the current format? Thanks.

    <?php get_header();?>
    <div id=”main”>
    <div id=”content”>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class=”post” id=”post-<?php the_ID(); ?>”>
    <p class=”date”>
    <span class=”month”>
    <?php the_time(‘M’) ?>
    </span>
    <span class=”day”>
    <?php the_time(‘d’) ?>
    </span>
    <span class=”year”>
    <?php the_time(‘Y’) ?>
    </span>
    </p>

    sagdude2002

    (@sagdude2002)

    I tried a variety of different combos of the code from http://uk2.php.net/manual/en/function.date.php but can’t get it to read the current date and keep the same format. Any other suggestions?

    sagdude2002

    (@sagdude2002)

    I figured it out. For each section (i.e. the month, day and year) you replace ‘the_time’ with the ‘date’ and put the word ‘echo’ in front of the word ‘date’. Here is how the final code looks:

    <?php get_header();?>
    <div id=”main”>
    <div id=”content”>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class=”post” id=”post-<?php the_ID(); ?>”>
    <p class=”date”>
    <span class=”month”>
    <?php echo date(‘M’) ?>
    </span>
    <span class=”day”>
    <?php echo date(‘d’) ?>
    </span>
    <span class=”year”>
    <?php echo date(‘Y’) ?>
    </span>
    </p>

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Make all pages show current date’ is closed to new replies.