Использование WP Query
Параметры времени
year (int) - год из 4 цифр (например, 2011).
monthnum (int) - номер месяца (от 1 до 12).
w (int) - неделя года (от 0 до 53). Использует команду MySQL WEEK. Режим зависит от опции "start_of_week".
day (int) - день месяца (от 1 до 31).
час (int) - час (от 0 до 23).
минута (int) - минута (от 0 до 60).
second (int) - Second (от 0 до 60).
m (int) - YearMonth (например, 201307).
Возвращает сообщения только за текущую дату:
$today = getdate();
$query = new WP_Query( 'year=' . $today["year"] . '&monthnum=' . $today["mon"] . '&day=' . $today["mday"] );
Возвращает сообщения только за текущую неделю:
$week = date('W');
$year = date('Y');
$query = new WP_Query( 'year=' . $year . '&w=' . $week );
Обратные сообщения за период с 1 по 15 марта 2010 года:
// Create a new filtering function that will add our where clause to the query
function filter_where( $where = '' ) {
// posts for March 1 to March 15, 2010
$where .= " AND post_date >= '2010-03-01' AND post_date < '2010-03-16'";
return $where;
}
add_filter( 'posts_where', 'filter_where' );
$query = new WP_Query( $query_string );
remove_filter( 'posts_where', 'filter_where' );
Обратные сообщения от 30 до 60 дней
// Create a new filtering function that will add our where clause to the query
function filter_where( $where = '' ) {
// posts 30 to 60 days old
$where .= " AND post_date >= '" . date('Y-m-d', strtotime('-60 days')) . "'" . " AND post_date <= '" . date('Y-m-d', strtotime('-30 days')) . "'";
return $where;
}
add_filter( 'posts_where', 'filter_where' );
$query = new WP_Query( $query_string );
remove_filter( 'posts_where', 'filter_where' );
Для более подробной информации нажмите здесь http://codex.wordpress.org/Class_Reference/WP_Query