好了,这就是我需要的,我需要在wp上回显自定义分类归档页面的永久链接。我可以获得对象ID,但我找不到一种方法来使用相同的id来获得分类固定链接。
这是我的代码示例:
<?php
get_field('services_1', $id);
// this returns the id of the taxonomy which is 22
// i tried to saved it into a variable like so:
$term = get_field('services_1', $id);
echo get_term_link( $term, 'type-of-services' ); ?>
?>这不起作用,我只是放弃尝试,任何帮助都将不胜感激。
发布于 2014-07-28 06:48:20
使用wp_list_categories
$args = array(
'taxonomy' => 'your_taxonomy',
'title_li' =>'',
'orderby' => 'name',
'parent' => 0
);
<ul> wp_list_categories($args); </ul>发布于 2014-07-28 12:10:25
我建议首先验证您传递给函数get_term_link的值是否正确。
http://<root>/wp-admin/edit-tags.php??action=edit&taxonomy=<taxonomy_name>&tag_ID=<term_id>&post_type=<post_type>然后检查<taxonomy_name>和<term_id>是否与示例中的匹配(‘服务类型’和22)。
https://stackoverflow.com/questions/24986165
复制相似问题