• (I think I posted this is the wrong section of the forum…sorry)
    Hi,
    I have this code snippet for my tags. It displays them in a list as links along with the tag count.

    <?php
    	// Select all the post tag IDs
    	$the_tags = $wpdb->get_col("SELECT term_id
    	FROM $wpdb->term_taxonomy WHERE taxonomy = 'post_tag'" );
    
    	// Loop over each ID, and grab associated data
    	foreach($the_tags as $tag_id) {
    		// Get information on the post tag
    		$post_tag = get_term( $tag_id, 'post_tag' );
    		// Print the tag name and count (how many posts have this tag)
    		echo '<li><a href="'. get_tag_link($tag_id).'">'.$post_tag->name.'</a><span>('.$post_tag->count.')</span></li> ';
    		// Unset the data when it's not needed
    		unset($post_tag);
    	}
    	?>

    I have two questions.
    1. How would I use this (i’ve altered it, it’s not my code) and change it to limit the amount of tags displayed to 15?

    2. I have some test tags set up and assigned to some test posts. When i click on a tag that has been used in my tag list will WP be looking for an archive.php file? Currently nothing happens when i click on one of my tags. I haven’t set up an archive.php file yet so I’m assuming that’s the issue but wanted to double check.

Viewing 1 replies (of 1 total)
  • Thread Starter jalacom

    (@jalacom)

    Ok so i jumped the gun and found I didn’t know about the tag.php file. So i’m in the process of creating it. I’ve duplicated my index.php file and need to alter it for my tag.php file to return only the results of the tag that was clicked. How would I do that? Here’s the beginning of the index.php loop:

    <?php $my_query = "showposts=5&cat=4"; $my_query = new WP_Query($my_query); ?><!-- Calls the main blogroll category -->
    
    	<?php if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post(); ?><!-- Starts the loop -->
    
    	<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

Viewing 1 replies (of 1 total)
  • The topic ‘Limit Tags displayed’ is closed to new replies.