2015-02-05 105 views
0

特别感谢我对最后两个问题的每一个回复,我还有另外两个重要的两个: 第一个:我需要下一个代码从一个我的自定义帖子类型的特定分类。我尝试用数组('fields'=>'proceeding')替换:array('fields'=>'all'),以仅从继续分类中获得meta术语,但它不起作用。有什么建议吗? :当从所有分类法中获取所有术语时,是否有任何方法让代码根据不同的分类法显示不同行上的术语?wordpress:如何获得单个自定义帖子类型的特定meta条款

foreach ((array) get_object_taxonomies($post->post_type) as $taxonomy) { 
    $object_terms = wp_get_object_terms($post->ID, $taxonomy, array('fields' => 'all')); 
    if ($object_terms) { 
     echo ': (- ' . $taxonomy . ': ';// I modify the output a bit. 
     $res = ''; 
     foreach ($object_terms as $term) { 
      $res .= '<a href="' . esc_attr(get_term_link($term, $taxonomy)) . '" title="' . sprintf(__("View all posts in %s"), $term->name) . '" ' . '>' . $term->name . '</a>, '; 
     } 
     echo rtrim($res,' ,').')';// I remove the last trailing comma and space and add a ')' 
    } 
} 
+1

你是什么意思,它没有工作。请提供确切的不良行为。 – 2015-02-05 15:56:01

+0

你好,当用array('fields'=>'proceeding')替换数组('fields'=>'all')时,没有任何内容出现,元语术语也没有分类法。 – nisr 2015-02-05 17:05:41

回答

0

如果你只是想从“程序”分类术语,你可以使用:

$object_terms = wp_get_object_terms($post->ID, 'proceeding'); 

你在把事情在不同线路上的问题并不完全清楚。如果您只是在字符串末尾添加

'<br />' 

,则下一个将在新行中。

+0

首先,我要感谢您回复:),它现在只显示来自'proceeding'的术语,但它显示了显示所有分类法的这些术语。例如:继续:URAM-2012 - 关键字:URAM-2012 - 作者:URAM-2012。请,我需要它只显示继续的条款,如:“继续:URAM-2012”。 – nisr 2015-02-05 22:14:40

相关问题