Skip to content

Commit

Permalink
Add support for taxonomies. #250
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleyfae committed May 20, 2021
1 parent 85e967e commit 728d9e1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion includes/class-book-grid-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,17 @@ protected function parse_args( $atts = array() ) {
);
}

// Taxonomies
foreach ( get_book_taxonomies( array( 'fields' => 'slug' ) ) as $taxonomy_slug ) {
if ( ! empty( $atts[ $taxonomy_slug ] ) && 'any' !== $atts[ $taxonomy_slug ] ) {
$this->args['tax_query'][] = array(
'taxonomy' => sanitize_text_field( $taxonomy_slug ),
'field' => 'id',
'terms' => absint( $atts[ $taxonomy_slug ] )
);
}
}

}

/**
Expand All @@ -166,4 +177,4 @@ public function get_results() {

}

}
}

0 comments on commit 728d9e1

Please sign in to comment.