自定义分类元素的Wordpress存档页面

时间:2012-11-19 20:13:13

标签: wordpress custom-post-type custom-taxonomy

我有自定义帖子类型clientgallery和自定义分类client

要获得所有画廊,我可以输入website.com/clientgallery。

但我想只展示特定客户的画廊,例如:website.com/clientgallery/miller

因此,miller应该像get参数一样。

我已经知道如何通过客户端获取图库,但我不知道如何让参数部分工作。

$args = array(
  'numberposts'     => -1, //limit the number of posts, set 0 if no limit required.
  'orderby'         => 'post_date', //order by post_date field.
  'order'           => 'DESC', //order by descending oder.
  'post_type'       => 'clientgallery', //the post type is custom post type 'News & Events'
  'post_status'     => 'publish', //post status is 'publish'
  'tax_query' => array(
    array(
      'taxonomy' => 'client', //custom taxonomy slug
      'field' => 'slug', //select taxonomy term by slug
      'terms' => $_GET['client'] //taxonomy term is called 'home-page'
    )
));

2 个答案:

答案 0 :(得分:2)

称之为taxonomy-client.php: 有关WordPress的模板层次结构,请参阅此处的所有信息:http://codex.wordpress.org/images/1/18/Template_Hierarchy.png

答案 1 :(得分:1)

如果您的分类法客户端仅与clientgallery帖子类型相关联,则website.com/client/miller应足以显示此客户端的clientgalleries列表。我在我的网站上测试过,它有效。还是我弄错了?