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
(@alcalt)
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.
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
(@alcalt)
Omg dude thanks that’s exactly what I needed.