Skip to content

Commit

Permalink
extended tax query realtionship and nesting
Browse files Browse the repository at this point in the history
  • Loading branch information
ashrafbd1496 committed Aug 11, 2021
1 parent 7a2f05f commit cb930a7
Showing 1 changed file with 29 additions and 18 deletions.
47 changes: 29 additions & 18 deletions taxquery.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,41 @@
/**
* Template Name: Tax Query Example
*/

$philosophy_query_args = array(
'post_type'=>'book',
'post_per_page'=>-1,
'tax_query'=>array(
'relation'=>'AND',
'post_type' => 'book',
'posts_per_page' => - 1,
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy'=>'language',
'field'=>'slug',
'terms'=>['english'],
'relation' => 'AND',
array(
'taxonomy' => 'language',
'field' => 'slug',
'terms' => array( 'english' )
),
array(
'taxonomy' => 'language',
'field' => 'slug',
'terms' => array( 'arabic' ),
'operator' => "NOT IN"
)
),
array(
'taxonomy'=>'language',
'field'=>'slug',
'terms'=>['bangla'],
'operator'=>'NOT IN'
)
),
'taxonomy' => 'genre',
'field' => 'slug',
'terms' => array( 'history' )
),


)
);

$philosophy_query_posts = New WP_Query($philosophy_query_args);
while ($philosophy_query_posts->have_posts()){
$philosophy_query_posts->the_post();
$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/>';
echo "<br/>";
}
wp_reset_query();

0 comments on commit cb930a7

Please sign in to comment.