【发布时间】:2013-10-11 09:11:28
【问题描述】:
我需要在 Wordpress 简码函数中通过名称获取指定标签的永久链接,简码如下所示:
function shortcode_hashtag($attr, $content){
$tagId = get_term_by('name', do_shortcode($content), 'tag');
return '<a href="'.get_tag_link($tagId).'" title="">'.do_shortcode($content).'</a>';
}
add_shortcode('hash', 'shortcode_hashtag');
输出链接是帖子本身的链接,而不是标签永久链接
【问题讨论】:
-
你有什么问题?上面的代码不起作用还是您正在寻找其他东西?
-
它不起作用,输出链接是帖子本身的链接,而不是标签永久链接
标签: php wordpress wordpress-theming