0
我正在构建复杂的标签云。在wordpress中使用元数据返回最流行的标签
Wordpress目前有一个名为'get_tags'的内置函数,我正在使用它来构建我的网站上使用的大多数杨树标签的列表。
继承人我当前工作的PHP函数:
function top_brand_tags($related_publication) {
$tag_data = '';
$tags = get_tags();
$counts = $tag_links = array();
foreach ((array) $tags as $tag)
{
$counts[$tag->name] = $tag->count;
$tag_links[$tag->name] = get_tag_link($tag->term_id);
}
asort($counts);
$counts = array_reverse($counts, true);
$i = 0;
foreach ($counts as $tag => $count)
{
$i++;
$tag_link = str_replace(' ', '-', wp_specialchars($tag));
$tag = str_replace(' ', ' ', wp_specialchars($tag));
if($i < 11)
{
if ($_GET['the_post_tag'] == $tag_link){$post_tag_class = "on";}else{$post_tag_class = "";}
$tag_data.= '<a href="'.site_url().'/see-all?the_post_tag='.$tag_link.'&related_publication='.$related_publication.'" >
<li class="filter-btn">'.ucfirst($tag).' ('.$count.')</li>
</a>';
}
}
return $tag_data;
}
我现在需要的,这样它可以让我在多彩键和值传递到修改此功能。该功能然后必须搜索具有与其关联的该键和值的所有帖子,并基于这个新标准返回最受欢迎的标签。
因此,要总结:我需要编写一个新的函数,将:
1 - 搜索包含特定元键和值
2的所有帖子 - 返回基于前10个最常用的标签这些结果。
伟大的工作。谢谢。 – richelliot 2014-09-03 16:54:46