Created
February 5, 2014 10:32
-
-
Save Manoz/8820857 to your computer and use it in GitHub Desktop.
Test: récupérer tous les posts plus vieux que le 1er décembre 2013.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="test"> | |
<p>Test: récupérer tous les posts plus vieux que le 1er décembre 2013.</p> | |
<?php | |
global $wpdb; | |
$query = " | |
SELECT post_title,post_date | |
FROM $wpdb->posts | |
WHERE post_date < '2013-12-01 00:00:00' | |
AND post_status = 'publish' | |
AND post_type = 'post' | |
ORDER BY post_date DESC | |
"; | |
$results = $wpdb->get_results( $query ); | |
// Open an unordered list | |
echo '<ul>'; | |
foreach ( $results as $result ) | |
{ | |
echo '<li>'; | |
echo '<time style="font-weight:bold" datetime="'.$result->post_date.'">'.$result->post_date.'</time>'; // The post date | |
echo '<span> '.$result->post_title.'</span>'; // the post title | |
echo '</li>'; // Close your list item | |
} | |
echo '</ul>'; // Close your unordered list | |
?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment