Created
July 30, 2014 14:53
-
-
Save jpcontrerasv/94bb85f3ef39a1af8dce to your computer and use it in GitHub Desktop.
Loop Ultimos 7 días
This file contains hidden or 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
<?php | |
function filter_where($where = '') { | |
//only show posts published within the last 30 days | |
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-7 days')) . "'"; | |
return $where; | |
} | |
add_filter('posts_where', 'filter_where'); | |
// Query posts | |
query_posts( 'cat=3&posts_per_page=1&orderby=rand' ); | |
// The Loop | |
if (have_posts()) : while ( have_posts() ) : the_post(); ?> | |
<?php the_content(); ?> | |
<?php | |
endwhile; endif; | |
//remove the filter | |
remove_filter('posts_where', 'filter_where'); | |
// Reset Query | |
wp_reset_query(); | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment