We just need a list of classifieds...

We would like to grab a list of classifieds posted in the previous X hours and display:

URL: /classifieds/displayListOfClassifeds.php?prevHours=24
(only a suggestion of course)
Cost - LinkedTitle - Author

This would be copied and pasted into our morning email sent to users.

Could you kindly supply the code to spit this out?


  • Vaughan

    Hi Brian,

    you would need to create a custom query for this, then add in the arguments for the date.

    $today = getdate();
    $args = array(
    	'date_query' => array(
    			'year'  => $today['year'],
    			'month' => $today['mon'],
    			'day'   => $today['mday'],

    I'm not exactly sure of how you would do this properly though, maybe with a custom template.

    Let me just ask one of our developers to see if he can come up with a quick solution for you.


  • Hoang Ngo

    Hi Brian,

    I hope you are well today.

    Vaughan has point the right way, for more detail, I think here is the params you need to query all classifieds

    $query = new WP_Query(array(
            'post_type' => 'classifieds',
            'post_status' => 'publish',
            'date_query' => array(
                'after' => date('Y-m-d H:i:s', strtotime('-24 hours'))
    $posts = $query->posts;

    After get the results, you can apply your logic.

    If you have any issues please don't hesitate to let us know so we can assist

    Best regards,
    Hoang Ngo

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.