Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6742381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:50:12+00:00 2026-05-26T11:50:12+00:00

i need to have a function that will echo the post that has been

  • 0

i need to have a function that will echo the post that has been posted today.

from 00.00 to 23.59 . ihave created a function but it is not giving the result i need
here is my function:

function todayNews() {
    $id = mysql_real_escape_string ($id);
    $sql = 'SELECT * FROM wp_posts WHERE  post_status = "publish" AND post_date = CURRENT_DATE  ORDER BY post_date DESC LIMIT 15';
    $res = mysql_query($sql) or die (mysql_error());

if (mysql_num_rows($res) !=0):
    while ($row = mysql_fetch_assoc($res)) {

    $title = ($row['post_title']);

    $old_date = $row['post_date'];             // returns Saturday, January 30 10 02:06:34
    $old_date_timestamp = strtotime($old_date);
    $new_date = date('H:i', $old_date_timestamp);

    $mycontent = ($row['post_content']);
    $mycontent = strip_tags($mycontent);
    $mycontent = substr($mycontent,0,350);
    $mycontent = preg_replace("/\[caption.*\[\/caption\]/", '', $mycontent); 

    $first_img = '';
    $my1content = $row['post_content'];
    $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $my1content, $matches); 
    $first_img = $matches [1] [0];
    if(empty($first_img)){ //Defines a default image
    $first_img = "/img/default.png";
    }

    echo '


    <ul class="li-sub">
                <li>
'.$title.'
</li>

        </ul>

    ';  
}
    else:
        echo 'There are no posts for today !';
    endif;

} // end  

Thank you !

EDIT:
Post_date have this format : Y-m-d H:i

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:50:12+00:00Added an answer on May 26, 2026 at 11:50 am

    You are comparing POST_DATE which is a datetime with CURRENT_DATE which is a Date , it won’t give any result.

    you can try the following SQL

    $sql = 'SELECT * FROM wp_posts WHERE  post_status = "publish" AND DATE(post_date) = CURRENT_DATE  ORDER BY post_date DESC LIMIT 15';
    

    This will convert the post_date to only date before comparing with current date.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function that i need to call on iframe mousemove(). But i
I've been working on trying to write a function that will grab the POST
I have a $.POST call that return the name of a function that need
in delphi7 i have a function that i need to return a array as
I have need for a function pointer that takes two arguments and returns a
I need to write a little ruby function that does word wrapping. I have
I have two classes that each need an instance of each other to function.
I need to have a routine/function/stored proc/whatever to archive particular accounts from our 'active'
I have a big form, that will be serialized by a jQuery function. The
I have an html table that pulls data from a DB. It has an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.