WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] bottom-border date shows up even when no date is returned (4 posts)

  1. JacobGrier
    Member
    Posted 8 years ago #

    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:
    http://jacobgrier.com/wp

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

  2. Beel
    Member
    Posted 8 years ago #

    That is because the header tags will display whether or not the date does. Include the tags in the function:
    http://codex.wordpress.org/Template_Tags/the_date

    <?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.

  3. JacobGrier
    Member
    Posted 8 years ago #

    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.

  4. Beel
    Member
    Posted 8 years ago #

    Glad to be of help.

Topic Closed

This topic has been closed to new replies.

About this Topic