Title: Conditional loop with taxonomies
Last modified: August 22, 2016

---

# Conditional loop with taxonomies

 *  Resolved [Alcalt](https://wordpress.org/support/users/alcalt/)
 * (@alcalt)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/conditional-loop-with-taxonomies/)
 * I create the custom post type **Book** and under it I have 2 custom taxonomy :**
   Novel** and **Comics**. I need to display my books like this:
 * Novel
    book-1 book-2 book-4
 * Comics
    book-3 book-5
 * I’m using a loop to display my books but I can’t figure how to filter them with
   my custom taxonomy. Anyone can help?
 * [https://wordpress.org/plugins/pods/](https://wordpress.org/plugins/pods/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [jurek2006](https://wordpress.org/support/users/jurek2006/)
 * (@jurek2006)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/conditional-loop-with-taxonomies/#post-5750394)
 * Have you tried with ‘where’ in params?
    If you have pods Books and e.g. taxonomy
   Type with two items: Novel, Comics you can do something like this:
 *     ```
       //loop for Novel
       $params = array( 'limit' => -1,
       	          'where'   => 'type.name LIKE "%Novel%"' );
       $pods = pods( 'books', $params );
       ...
       ```
   
 * I’m not sure about ‘name’ in type.name, maybe it should be type.title. I don’t
   remember how it’s called in Pods.
 *  Thread Starter [Alcalt](https://wordpress.org/support/users/alcalt/)
 * (@alcalt)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/conditional-loop-with-taxonomies/#post-5750430)
 * Thanks but I’ve tried this already . I tried **‘where’ => ‘category.name=”Novel”‘**
   since **where (Pods) **have _category_ but it didn’t work. I also tried with **‘
   category.slug**‘ but I got the same result.
 *  [jurek2006](https://wordpress.org/support/users/jurek2006/)
 * (@jurek2006)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/conditional-loop-with-taxonomies/#post-5750433)
 * When you do normal loop (without where), is it possible to get to this data in
   category.name or category.slug, can you print them?
 * Is the category custom pods taxonomy?
 * I’ve tried. For me it works perfect, even if one book is novel and also comics(
   at least with pods 2.5)
    _I haven’t used ‘category’ because WP doesn’t let me
   to name pods taxonomy like this, nor ‘type’ (it printed pods name) so I named
   custom pods taxonomy ‘kind’_:
 *     ```
       <h1>NOVEL</h1>
       				<?php
       				//------------------------ NOVEL
   
       				$params = array('limit' => -1,
       								'where'   => 'kind.name LIKE "%Novel%"');
       				$pods = pods('book', $params);
                       if ( $pods->total() > 0 ) {
                           while ( $pods->fetch() ) {
                               //Put field values into variables
                               $name = $pods->display('name');
       						$type = $pods->display('kind');
       				?>
                       	<h2><?php echo $name; ?></h2>
                           <p><?php  echo $type ?></p>
                       <?php
       					}//while ( $pods->fetch() )
       				}
       				else
       					echo 'Error';//( $pods->total() > 0 )
       				?>
       				<h2>COMICS</h2>
       				<?php
       				$params = array('limit' => -1,
       				'where'   => 'kind.name LIKE "%Comics%"');
       				$pods = pods('book', $params);
                       if ( $pods->total() > 0 ) {
                           while ( $pods->fetch() ) {
                               //Put field values into variables
                               $name = $pods->display('name');
       						$type = $pods->display('kind');
       				?>
                       	<h2><?php echo $name; ?></h2>
                           <p><?php  echo $type ?></p>
                       <?php
       					}//while ( $pods->fetch() )
       				}
       				else
       					echo 'Error';//( $pods->total() > 0 )
       				 ?>
       ```
   
 * I got output like this:
 *     ```
       NOVEL
       aaa
       novel
   
       ccc
       novel
   
       ddd
       comics and novel
   
       COMICS
       bbb
       comics
   
       ddd
       comics and novel
       ```
   
 *  Thread Starter [Alcalt](https://wordpress.org/support/users/alcalt/)
 * (@alcalt)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/conditional-loop-with-taxonomies/#post-5750443)
 * Omg dude thanks that’s exactly what I needed.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Conditional loop with taxonomies’ is closed to new replies.

 * ![](https://ps.w.org/pods/assets/icon.svg?rev=3286397)
 * [Pods - Custom Content Types and Fields](https://wordpress.org/plugins/pods/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/pods/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/pods/)
 * [Active Topics](https://wordpress.org/support/plugin/pods/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/pods/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/pods/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Alcalt](https://wordpress.org/support/users/alcalt/)
 * Last activity: [11 years, 4 months ago](https://wordpress.org/support/topic/conditional-loop-with-taxonomies/#post-5750443)
 * Status: resolved