wordpress调用随机tag标签

非插件纯代码实现wordpress调用随机tag标签的方法 <?php // 获取所有标签 $tags = get_tags(); // 如果存在标签 if ($tags) { // 随机排序标签数组 shuffle($tags); // 定义计数器 $count = 0; // 遍历标签 foreach ($tags as $tag) { // 如果计数器达到20,停止循环 if (…

wordpress调用指定栏目下的tag标签相关文章列表

<?php global $post; $post_tags = wp_get_post_tags($post->ID); if ($post_tags) { foreach ($post_tags as $tag) { // 获取标签列表 $tag_list[] .= $tag->term_id; } $cat = get_the_category(); foreach($cat as $key=>$category){ $catid = $category->term_id; } // 随机获取标签列表中的一个…

按分类调用标签 调用指定分类下的TAG

<?php query_posts('category_name=news'); if (have_posts()) : while (have_posts()) : the_post(); if( get_the_tag_list() ){ echo $posttags = get_the_tag_list('<li class="jquery">','</li><li>','</li>'); } endwhile; endif; wp_reset_query(); ?> 在制作wordpress主题时,有…