WordPress.org

Ready to get started?Download WordPress

Forums

Using "hours ago/days ago" date format (2 posts)

  1. hmichaels
    Member
    Posted 5 years ago #

    Hello there,

    I've been searching for about an hour with no success, so I thought I'd drop by the forums with a plea for hl3p.

    I'm developing a custom theme for a news site I'll be launching in the near future, and I'd like to be able to use relative dates for some parts of my site. I'm aware of the plugin WP-RelativeDate but it doesn't do what I want it to do without heavily modifying the code, which leads to lots of redundant if statements etc. - and saying that, I'm not the best coder in the world.

    I want to have a news feed on my page that lists the previous x number of posts by title only with a small relative date next to it, i.e.:

    Sample post title (< 1h)
    Sample post title 2 (3h)
    Sample post title 3 (2d)
    And more... (5d)
    And more still... (18d)

    I've read somewhere that WordPress has built in "hours ago" and "days ago" tags, but I couldn't find them anywhere. Does anybody know what they are and how to use them?

  2. yoyo
    Member
    Posted 4 years ago #

    find:
    <?php the_date(); ?>

    and replace it with

    <?php relative_post_the_date(); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic