Hi,
does anyone know how to exclude old posts by year (ex. in 2004 and 2005) from displaying on the homepage?
Thank you.
Hi,
does anyone know how to exclude old posts by year (ex. in 2004 and 2005) from displaying on the homepage?
Thank you.
To exclude posts, using the WordPress Default theme for example, in the wp-content/themes/default/index.php file, just before the line:
<?php if (have_posts()) : ?>
put this:
<?php
function filter_where($where = '') {
//retrieve posts dated Jan 1, 2006 and newer
$where .= " AND post_date >= '2006-01-01'";
return $where;
}
add_filter('posts_where', 'filter_where');
query_posts($query_string);
?>
The query_posts() article explains the arguments in detail.
Related:
Stepping Into Template Tags
Stepping Into Templates
Template Hierarchy
Hi Michael,
thank you so much!!!! it works! :)
thanks again really..
more power!
This topic has been closed to new replies.