繁体   English   中英

pods:按自定义分类查询海关帖子过滤器

[英]pods: Query customs posts filter by custom taxonomy

使用荚,我创建了一个新的自定义后类型命名staff_member其中包含一个字段 staff_department_relationship是关系到一个自定义分类类型的关系 staff_department 还要注意, staff_department_relationship 字段格式 dropdownsingle select

现在,我想查询来自某个特定部门的所有工作人员,并按照http://pods.io/docs/code/pods/find/尝试了很多不同的方法,但没有成功。 有时我会收到数据库错误或根本没有帖子:

$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);

有人知道发生了什么吗?

定义块,而不是名称“ where” =>“ staff_department”。 slug =“ some_custom_taxonomy_slug”'

分类的代码列表post_type-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.'; }

?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM