text WORDPRESS:从类别中获取所有标记

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text WORDPRESS:从类别中获取所有标记相关的知识,希望对你有一定的参考价值。

//FUNCTION FILE
function get_category_tags($args) {
    global $wpdb;
	$tags = $wpdb->get_results
	("
		SELECT DISTINCT terms2.term_id as tag_id, terms2.name as tag_name, null as tag_link
		FROM
			wp_posts as p1
			LEFT JOIN wp_term_relationships as r1 ON p1.ID = r1.object_ID
			LEFT JOIN wp_term_taxonomy as t1 ON r1.term_taxonomy_id = t1.term_taxonomy_id
			LEFT JOIN wp_terms as terms1 ON t1.term_id = terms1.term_id,

			wp_posts as p2
			LEFT JOIN wp_term_relationships as r2 ON p2.ID = r2.object_ID
			LEFT JOIN wp_term_taxonomy as t2 ON r2.term_taxonomy_id = t2.term_taxonomy_id
			LEFT JOIN wp_terms as terms2 ON t2.term_id = terms2.term_id
		WHERE
			t1.taxonomy = 'category' AND p1.post_status = 'publish' AND terms1.term_id IN (".$args['categories'].") AND
			t2.taxonomy = 'post_tag' AND p2.post_status = 'publish'
			AND p1.ID = p2.ID
		ORDER by tag_name
	");
	$count = 0;
	foreach ($tags as $tag) {
		$tags[$count]->tag_link = get_tag_link($tag->tag_id);
		$count++;
	}
	return $tags;
}
//THEME
    $args = array('categories' =>the_category_ID( false ));
    $tags = get_category_tags($args);

以上是关于text WORDPRESS:从类别中获取所有标记的主要内容,如果未能解决你的问题,请参考以下文章

从 WordPress 中的特定类别获取置顶帖子

用于 WordPress 的 PHP 片段,用于获取所有产品子类别

从 WordPress 获取 WooCommerce 产品类别

从单个帖子中获取 Wordpress 类别

从Wordpress中的任何类别中获取顶级类别

获取Wordpress查询中的所有类别,自定义字段值?