function.phpへ記入したコードを特定のquery_postsへ適応させる方法
-
function.phpに下記のコードを記入したのですが、すべてのクエリに適応されてしましました。
これを一部のクエリにのみ適応させる方法を教えてください。
function.phpへのコードの追加ではなく、query_postsのみを使用した方法でも大丈夫です。以下 http://wpdocs.sourceforge.jp/テンプレートタグ/query_postsより抜粋
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_posts( $query_string );
2件の返信を表示中 - 1 - 2件目 (全2件中)
2件の返信を表示中 - 1 - 2件目 (全2件中)
- トピック「function.phpへ記入したコードを特定のquery_postsへ適応させる方法」には新たに返信することはできません。