Forums

Tags on the Category Pages (1 post)

  1. evilnrj
    Member
    Posted 2 years ago #

    Hey, I'm trying to make the categories list all the tags in it and link to the tag page. So here's the code i have so far:

    query_posts('category_name=Rant&showposts=-1');
    	if (have_posts()) : while (have_posts()) : the_post();
            $posttags = get_the_tags();
    		if ($posttags) {
    			foreach($posttags as $tag) {
    				$all_tags_arr[] = $tag -> name;
    			}
    		}
    	endwhile; endif;
    
    	$tags_arr = array_unique($all_tags_arr); //REMOVES DUPLICATES
    	//echo '<pre>'.print_r($tags_arr, true).'</pre>';
    
           foreach ($tags_arr as $tag) {
               echo '<a href="http://yoursite.net/tag/'.$tag.'">'.$tag.'</a>, ';
           }

    Somewhere along the way something is terrible wrong though, all category pages list only the posts & tags from the category "Rant" - if i remove that line, all posts & tags from ALL categories show on ALL the category pages. Hope someone can help me out! Thanks ;)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.