简体   繁体   English

自定义帖子类型的高级WordPress自定义分类

[英]Advanced WordPress Custom Taxonomy on Custom Post Type

I have a client I'm creating a custom post type to handle awards they've won and so they can easily update new awards. 我有一个客户,我正在创建一个自定义帖子类型,以处理他们所获得的奖项,因此他们可以轻松地更新新奖项。 The awards are given to many different products of theirs and also at different years. 该奖项分别授予他们的许多不同产品以及不同年份。 So the awards can be won multiple times. 因此,奖项可以多次获得。 I need to list the products each award has won, as well as display the awards on a product page that correspond to that product. 我需要列出每个奖项所获得的产品,并在与该产品相对应的产品页面上显示奖项。 Fairly straight forward, except I need to also add the year the award was won. 相当简单,除了我还需要加上获奖的年份。 They could win the same award for the same product on different years. 他们可以在不同年份获得相同产品的相同奖项。 And they could also win the same award in the same year for multiple products. 他们还可以在同一年获得多种产品的同一奖项。 They want to be able to show all awards won in a select year, as well as be able to list all awards a product has won, including any multiples the product has won. 他们希望能够显示选定年份中赢得的所有奖项,并能够列出产品已赢得的所有奖项,包括该产品获得的任何倍数。 Right now I have it set up as categories where the year is the parent and the product is the child... But this isn't elegant at all and in future years each product would have to be entered in all over again. 现在,我将其设置为类别,其中年份为父级,产品为子级……但这一点都不优雅,在未来的几年中,每种产品都必须重新输入。 Anyone know of a way to create a more advance taxonomy so that I can organize each award by year and product that won the award, without having to create repeat product categories in each year? 有谁知道一种创建更高级分类法的方法,这样我就可以按年度和获得该奖项的产品组织每个奖项,而不必每年创建重复的产品类别?

This is an example of how I have it setup currently 这是我目前如何设置的一个示例

AWARDS
2017
 - Product 1
 - Product 2
 - Product 3
2016
 - Product 1
 - Product 2
 - Product 3
2015
 - Product 1
 - Product 2
 - Product 3

It seems you need many-to-many relationships between your entities. 看来您的实体之间需要多对多关系。 You should try ACF plugin, it gives you the possibility to easely create those type of relationships: https://www.advancedcustomfields.com/resources/relationship/ 您应该尝试使用ACF插件,它使您可以轻松创建这些类型的关系: https : //www.advancedcustomfields.com/resources/relationship/

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

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