0

このクエリを使用して投稿を表示しています。

$today = getdate();
$year=$today["year"];
$month=$today["mon"];
$day=$today["mday"];

query_posts( $query_string.'order=ASC' . '&post.status=future,publish'.'&year='.$year.'&monthnum='.$month );
?>

ここで、今日公開された、または将来公開される投稿のみを表示するフィルターを追加したいと考えています。

例: 今日は 3 月 22 日です。PostA は 3 月 1 日に公開され、PostB は今日公開され、PostC は 3 月 24 日に公開されます (ステータス 'future' は既にクエリに含まれているため、表示されます)。クエリの新しいフィルターは、PostB と PostC のみを表示する必要があります。

よろしくお願いします!

:-)

4

2 に答える 2

0

これを試して :

// Create a new filtering function that will add our where clause to the query
  function filter_where( $where = '' ) {
$today = date('Y-m-d');
  // posts for today and future
$where .= " AND post_date >= $today ";
return $where;
  }

  add_filter( 'posts_where', 'filter_where' );
  $query = new WP_Query( $query_string );
  remove_filter( 'posts_where', 'filter_where' );
于 2013-03-23T04:53:04.197 に答える