钩posts_where
筛选条件并将其添加到sql查询:
function wpse8170_filter_where( $where = \'\' ) {
$where .= sprintf( " AND post_date >= \'\'", date( \'Y-m-d\' ) );
return $where;
}
// add your hook
add_filter( \'posts_where\', \'wpse8170_filter_where\' );
// get pages
$pages = get_children( array(
\'post_status\' => \'future,publish\',
\'post_type\' => \'event\',
\'sort_order\' => \'DESC\'
) );
// remove your hook to not have influence on other get posts queries
remove_filter( \'posts_where\', \'wpse8170_filter_where\' );
foreach ( $pages as $post ) {
setup_postdata($post);
?><h3><?php echo the_title(); ?> - <?php the_date(); ?></h3><?php
}
wp_reset_query();