Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- query_posts(array(
- array('post'), 'tax_query' => array(array( 'taxonomy' => 'post_format',
- 'field' => 'slug',
- 'terms' => array('post-format-image'))),
- 'cat' => '-173',
- 'post_status' => 'publish')
- );'
- // This takes your current query, that will have the filtering part added to.
- $query_string = array(
- 'post_type' => 'post',
- 'tax_query' => array(array( 'taxonomy' => 'post_format',
- 'field' => 'slug',
- 'terms' => array('post-format-image'))),
- 'cat' => '-173',
- 'post_status' => 'publish');
- // Create a new filtering function that will add our where clause to the query
- function filter_where( $where = '' ) {
- // posts in the last 30 days
- $where .= " 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' );
- function wpse52070_filter_where( $where = '' , $query) {
- if( $query->is_main_query() && is_page( 'foobar' ) ){
- // posts in the last 30 days
- $where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
- }
- return $where;
- }
- add_filter( 'posts_where', 'wpse52070_filter_where' );
- $query_string = array(
- 'post_type' => 'post',
- 'date_query' => array(
- 'after' => '2012-04-01'
- ),
- 'tax_query' => array(array( 'taxonomy' => 'post_format',
- 'field' => 'slug',
- 'terms' => array('post-format-image'))),
- 'cat' => '-173',
- 'post_status' => 'publish');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement