我使用一些自定义分类法在我的网站… movies_type
(是其中之一)和有4个术语:
-
movie
, -
tvseries
, -
concert-and-ceremony,
-
documentary
我在每个产品上只标记了其中一个术语。
我如何针对那些具有相同术语的产品?
谢谢
您可以使用has_term() WordPress函数使用自定义分类法中的术语来定位您的产品,就像产品类别的自定义分类法是"product_cat"一样
例如,你可以这样使用:
if ( has_term( 'movie', 'movies_type' ) ) {
// Do something
} elseif ( has_term( 'tvseries', 'movies_type' ) ) {
// Do another thing
}
这应该对你有用…
对于产品类别,您将使用
'product_cat'
自定义分类法:
if ( has_term( 'clothing', `'product_cat'` ) ) {
// Do something
}
对于产品标签您将使用'product_tag'
自定义分类法:
if ( has_term( 'books', 'product_tag' ) ) {
// Do something
}