0

Is there any way to list my posts by tags ?

i need to alter the URL too...

like mysite.com/tags/mytag will list all the posts having 'mytag' as tag.

0

You could use the Posts By Tag plugin.

0

You could use this snippet in your theme.

//-------------------------------------------------------------
// List Posts by Tag
//-------------------------------------------------------------

// Grab 5 posts by default

function list_posts_by_tag( $tag, $show=5 ) {

     global $post;

     $posts = query_posts('tag=' . $tag . '&showposts=' . $show );

     ?>

     <ul class="tagged-list">

          <?php foreach ($posts as $post ) : setup_postdata($post); ?>

               <li class="tagged-item"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></li>

          <?php endforeach;

          //Reset Query
          wp_reset_query();

          ?>

     </ul>

     <?php }

(from groupmindmedia.com)

You'd need to add that code to functions.php, and then add a call to the function in your theme:

list_posts_by_tag( "cats", 5 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.