[英]wordpress : how to get specific meta terms on single custom post type
with special thanks to every response on my last two questions, i have another important two: first : i need the next code to get meta terms from one specific taxonomy of my custom post type. 特别要感谢我对最后两个问题的每一个回答,我还有另一个重要的两个问题: 第一 :我需要下一个代码来从我的自定义帖子类型的一种特定分类法中获取元术语。 i tried to replace: array('fields' => 'all') with array('fields' => 'proceeding') to get the meta terms only from the proceeding taxonomy, but it didn't work.
我试图将array('fields'=>'all')替换为array('fields'=>'proceeding')以仅从进行分类法中获取元术语,但是它不起作用。 any suggestions please?
有什么建议吗? second : is there any way to let the code show the terms on different rows according to the different taxonomies when getting all terms from all taxonomies?
第二 :从所有分类法中获取所有术语时,有什么方法可以让代码根据不同的分类法在不同的行中显示术语?
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 ')'
}
}
If you just want terms from the 'proceeding' taxonomy, you can use: 如果只需要“进行中”分类法中的术语,则可以使用:
$object_terms = wp_get_object_terms($post->ID, 'proceeding');
Your question on putting things on different lines is not entirely clear. 您关于将事物置于不同界线的问题尚不完全清楚。 If you just add
如果你只是添加
'<br />'
at the end of the string, then the next one will be on a new line. 在字符串的末尾,那么下一个将在新行上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.