doudou5101 2015-09-21 06:16
浏览 38
已采纳

按自定义帖子类型限制自定义分类法下拉列表

I have 2 custom post types connected to the same custom taxonomy. On a particular page I needed to filter one particular post type using the filter that I created for my custom taxonomy. I was able to get a dropdown of my custom taxonomy using <?php wp_dropdown_categories( $args ); ?> but what I noticed was that it listed all the terms for which atleast one of the 2 custom post types had a post linked to it.

Here's an example of what I'm trying to do:
1. I have 2 custom post types: Cars and Bikes
2. I have a custom taxonomy (Location)
3. On a specific page, I need to filter the post type Cars using the dropdown that I created for my taxonomy
4. The problem that I'm facing is that the dropdown for my taxonomy Location, lists the locations that even posts from the Bikes post type are also connected to. So for example, if I have posts from the Cars post type connected to USA, UK, Australia and a post from the Bikes post type connected to Brazil, the dropdown for my custom taxonomy lists the 'Brazil' term too even though none of the Cars posts are linked to it.

Is it possible to restrict the dropdown for taxonomies to one custom post type?

  • 写回答

1条回答 默认 最新

  • duanlingzei0170 2015-11-30 06:38
    关注

    I asked the same question on the Wordpress Stackexchange site and got the answer. Linking to it in case anyone else is interested in it: https://wordpress.stackexchange.com/questions/207655/restrict-taxonomy-dropdown-to-post-type

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题