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

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

报告相同问题?

悬赏问题

  • ¥50 comsol稳态求解器 找不到解,奇异矩阵有1个空方程返回的解不收敛。没有返回所有参数步长;pid控制
  • ¥15 怎么让wx群机器人发送音乐
  • ¥15 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功