Created
March 11, 2013 15:38
-
-
Save alwayscoding/5135112 to your computer and use it in GitHub Desktop.
WORDPRESS: TAGS IN A CATEGORY
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query_posts('category_name=category-slug'); | |
if (have_posts()) : | |
while (have_posts()) : the_post(); | |
$posttags = get_the_tags(); | |
if ($posttags) { | |
foreach($posttags as $tag) { | |
$all_tags_arr[] = $tag->name; //USING JUST $tag MAKING $all_tags_arr A MULTI-DIMENSIONAL ARRAY, WHICH DOES WORK WITH array_unique | |
} | |
} | |
endwhile; | |
endif; | |
$tags_arr = array_unique($all_tags_arr); //REMOVES DUPLICATES | |
foreach ($tags_arr as $tag) { | |
# code... | |
echo $tag; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment