如何设置wordpress热门标签显及自定义标签?今天一起了解一下。在wordpress中我们常常需要使用标签调用,方便去阅读同标签下的文章,我们比较常见的就是如下的热门标签样式,只要使用下面的代码函数,复制到相应的位置就可以出现以a链接为开头的15个按文章量排序的热门标签。

<?php wp_tag_cloud( array ( \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’unit\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ => \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’px\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’order\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ => \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’RAND\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’,\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’taxonomy\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ => \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’number\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ => 15 ,\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’hide_empty\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ => false) ); ?>

当然如果你想自定义标签的默认代码,可以通过以下的代码来调用,下面的代码中显示了标签的文章数量,以及可以自定义标签前后的代码样式,很方便。

<?php

$tags_list = get_tags( array(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’number\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ => \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’18772\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’orderby\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ => \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’order\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ => \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’DESC\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’hide_empty\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ => false) );

shuffle($tags_list);

$count=0;

if ($tags_list) {

foreach($tags_list as $tag) {

$count++;

echo \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'<a title=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ . $tag->count . \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’个话题\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\” href=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’.get_tag_link($tag->term_id).\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\” target=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”_blank\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\” rel=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”noopener noreferrer\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”>\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’.$tag->name.\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'</a>\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’;

if( $count >20 ) break;

}

}

?>

相关新闻

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

联系我们

联系我们

151-1101-0018

在线咨询:
邮件:30115776@qq.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
关注微信
分享本页
返回顶部