簡體   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