如何找出wordpress分類標識?如何找出wordpress分類標識? ...不是術語ID
我想建立一個長期存在的查詢......
if (term_exists(array(
'term_id' => 4,
'term_taxonomy_ID' => x
)))
但我無法弄清楚如何找出我的分類叫做ID:「文件格式」
任何幫助將是非常感謝。
Josh
如何找出wordpress分類標識?如何找出wordpress分類標識? ...不是術語ID
我想建立一個長期存在的查詢......
if (term_exists(array(
'term_id' => 4,
'term_taxonomy_ID' => x
)))
但我無法弄清楚如何找出我的分類叫做ID:「文件格式」
任何幫助將是非常感謝。
Josh
你試過這個嗎?
<?php
$terms = get_the_terms($post->ID , 'file-formats');
if($terms) {
foreach($terms as $term_name) {
echo $term_name->term_id."<br />";
}
}
?>
祝你好運:)
試試這個:http://codex.wordpress.org/Function_Reference/get_taxonomies 或 http://codex.wordpress.org/Function_Reference/get_term
試試這個:
<?php $terms = get_the_terms($post->ID , 'taxonomy-name');
if($terms) {
foreach($terms as $term) {
echo $term->term_id.'<br />';
}
}
?>
對不起,我想我不小心編輯了你編輯你的回覆,不知道那是怎麼回事。我不太確定你是否瞭解我之後的事情。我只需要找出我的分類標識,以便完成我的查詢。 http://codex.wordpress.org/Function_Reference/term_exists 因爲我似乎無法得到這個工作... http://stackoverflow.com/questions/9617533/wordpress-term-exist-not-echoing -anything 因此,我最後的嘗試是使用'term_taxonomy_ID'而不是'term_taxonomy',我認爲它不起作用,但我無法親自弄清楚如何將我的分類組分配給查詢 – Joshc 2012-03-09 12:51:52
這只是返回我的任期?我對術語和分類法感到困惑嗎?我雖然在一個分類組中有一個術語 – Joshc 2012-03-09 12:58:12
謝謝,我嘗試這樣做了,但它返回項ID ,我需要找出我的分類標識。我的分類稱爲'文件格式',但我需要它的ID。 – Joshc 2012-03-09 12:43:56