Support » Fixing WordPress » bottom-border date shows up even when no date is returned

  • Resolved JacobGrier


    I want the date for posts to show up only once per day, so I call it at the beginning of the loop like this:

    <h2 class="date"><?php the_date();?></h2>

    I also want a line to appear below the date, so I give the h2 date class this attribute:
    border-bottom: 1px solid #000000;

    Since the date function only returns once per day, the text only appears once. But that bottom border appears between every entry and looks totally pointless.

    An example is up at the top of my working template:

    If anyone knows how to solve this problem, I would appreciate it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • That is because the header tags will display whether or not the date does. Include the tags in the function:

    <?php the_date(”, ‘<h2 class=”date”>’, ‘</h2>’); ?>

    P.S. The link I provided is to the codex and is the first place you should go for answers (unless you search for same here). People put a lot of work into it and most of the questions asked here are already answered there.

    Thank you, Beel. Worked perfectly.

    I’d tried that page in the Codex (usually very useful), but the answer I needed was under a heading that wasn’t suggestive of my problem.

    Glad to be of help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘bottom-border date shows up even when no date is returned’ is closed to new replies.