If post_date is old then display txt (3 posts)

  1. markie1
    Posted 6 years ago #

    I'm looking for an if statement to check if the post has been made in the last 30 days. if not, for it to post a message at the end of the post saying it's an old post.

  2. MichaelH
    Posted 6 years ago #

    $mylimit = 46 * 86400; //days * seconds per day
    $post_age = date('U') - mysql2date('U', $post->post_date_gmt);
    if ($post_age < $mylimit) {
    echo 'this post was made in the last 46 days ';
  3. alin1987
    Posted 6 years ago #

    heelo! Do you know how to display total number of posts published today ?

    $post_date = mysql2date("Ymd", $post->post_date_gmt);
    $numpost = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish' And post_date==post_date_gmt");

    echo $numpost;

    do not work

Topic Closed

This topic has been closed to new replies.

About this Topic