-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathtaxquery.php
42 lines (38 loc) · 1010 Bytes
/
taxquery.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* Template Name: Tax Query Example
*/
$philosophy_query_args = array(
'post_type' => 'book',
'posts_per_page' => - 1,
'tax_query' => array(
'relation' => 'AND',
array(
'relation' => 'AND',
array(
'taxonomy' => 'language',
'field' => 'slug',
'terms' => array( 'english' )
),
array(
'taxonomy' => 'language',
'field' => 'slug',
'terms' => array( 'bangla' ),
'operator' => "NOT IN"
)
),
array(
'taxonomy' => 'genre',
'field' => 'slug',
'terms' => array( 'horror' )
),
)
);
$philosophy_posts = new WP_Query( $philosophy_query_args );
//echo $philosophy_posts->found_posts;
while ( $philosophy_posts->have_posts() ) {
$philosophy_posts->the_post();
the_title();
echo "<br/>";
}
wp_reset_query();