Using pods, I've created a new custom post type named staff_member
which contains a field staff_department_relationship
of type Relationship that is related to a custom taxonomy staff_department
. Also note that the staff_department_relationship
field is a single select
of format dropdown
.
Now I'd like to query all staff members from a particular department and have tried a lot of different things as per http://pods.io/docs/code/pods/find/ but without much success. I sometimes get a DB error or no posts at all:
$params = array(
'limit' => -1,
// 'where' => 'staff_department_relationship.staff_department = "some_custom_taxonomy_slug"'
'where' => 'staff_department.name = "some_custom_taxonomy_slug"'
);
$pods = pods('staff_member', $params);
Anyone with any idea what's going on?
Defines slug instead of name 'where' => 'staff_department. slug = "some_custom_taxonomy_slug"'
Code List post_type for taxonomy - PODS Wordpress
<?php
$params = array(
'limit' => -1,
'where'=>"TaxonomySlug.Slug = 'TaxonomyTermSlug'" ,
);
$pods = pods( 'NamePostypeHere' )->find( $params );
if ( $pods->total() > 0 ) {
while( $pods->fetch() ) {
//reset id
$pods->id = $pods->id();
//get the template
$temp = $pods->template( 'NameTemplateHere' );
//output template if it exists
if ( isset( $temp ) ) { ?>
<?php echo $temp; ?>
<?php }
}
//pagination
echo $pods->pagination();
}
else { echo 'No content found.'; }
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.