0
我希望能夠顯示自定義帖子類型的所選分類詞。因此,例如,父類別是「行業」。子類別是「餐廳,網頁設計等」。選擇的類別是「網頁設計」。我需要在我的網站的前端顯示「網頁設計」,看起來像這個「行業 - 網頁設計」。如何在Wordpress中顯示選定的分類詞?
我希望能夠顯示自定義帖子類型的所選分類詞。因此,例如,父類別是「行業」。子類別是「餐廳,網頁設計等」。選擇的類別是「網頁設計」。我需要在我的網站的前端顯示「網頁設計」,看起來像這個「行業 - 網頁設計」。如何在Wordpress中顯示選定的分類詞?
你會想嘗試這樣的:
<div class="yourelement">
<p>Industry - <?php the_terms($post->ID, 'industry');?> </p>
</div>
我只是猜測,工業蛞蝓只是行業,但是你要仔細檢查。
的法典條款去更詳細討論它的功能,以及如何顯示更多選項: https://codex.wordpress.org/Function_Reference/the_terms
應該針對自定義文章類型工作,但如果不採取看看這個抄本以及get_the_terms(https://開頭codex.wordpress.org/Function_Reference/get_the_terms) – buschschwick 2015-03-31 20:02:36
這似乎沒有辦法。這是我在網上找到的,但這只是顯示所有條款。我只需要選擇的條款。 <?php $ term_id = 25; $ taxonomy_name ='project-categories'; $ termchildren = get_term_children($ term_id,$ taxonomy_name); foreach($ termchildren as $ child){ $ term = get_term_by('id',$ child,$ taxonomy_name_name); echo'