views:

332

answers:

3

I may just be missing this functionality, but does anyone know if there is a widget available:

I need to list the subject for all the entries that are associated with a given tag.

For example: I have 5 articles tagged with "Tutorial", I'd like to see a list as follows:

Tutorial 1 - Installing the app Tutorial 2 - Customizing Tutorial 3 - Advanced edits Tutorial 4 - User managment

Does functionality like this exists in wordpress allready?

+1  A: 

If you are comfortable with hacking WP you can try adding to your sidebar with wp_list_pages, http://codex.wordpress.org/Template_Tags/wp_list_pages.

Or there are plug-ins like Simple-Tags(http://wordpress.org/extend/plugins/simple-tags/) that help you manage your tags.

The nice thing about WordPress is there are lots of plug-ins available that can add functionality that the base app does not ahve, a quick search for plug-ins for tabs(http://wordpress.org/extend/plugins/search.php?q=tag) returned quite a list, sure it's a lot to dig through but that also helps you see what is available.

Sean
+1  A: 

So i found an article on using custom queries. I modified the script to pull a specific tag, in this case "Open Source".

<?php 
$querystr = "SELECT wposts.* 
             FROM $wpdb->posts wposts, $wpdb->terms wterms, $wpdb->term_relationships wterm_relationships, $wpdb->term_taxonomy wterm_taxonomy 
             WHERE wterm_relationships.object_id = wposts.ID 
             AND wterm_relationships.term_taxonomy_id = wterm_taxonomy.term_taxonomy_id 
             AND wterms.term_id = wterm_taxonomy.term_id 
             AND wterm_taxonomy.taxonomy = 'post_tag' 
             AND wterms.name = 'Open Source' 
             AND wposts.post_status = 'publish' 
             AND wposts.post_type = 'post' 
             ORDER BY wposts.post_date DESC";

     $pageposts = $wpdb->get_results($querystr, OBJECT);

?>

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

       <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title('<li>', '</li>'); ?></a>
      <?php endforeach; ?>
    <?php else : ?>

    <?php endif; ?>

If you only want to list pages for one specific tag then this would work. However, say you wanted to give a listing of pages for each tag based on the current articles listed on the page.

You might create an array of all the tags using the get_the_tags() function during The Loop and then use that array to dynamically generate the WHERE statement for the query.

Scott Gottreu
A: 

Just saw Scott Gottreu's answer and it's great! My PHP knowledge isn't terrific, so I figured I'd post here hoping to get some further info. I want to do the same thing for a tag, but break it down into a list by month. So for example:

Month Year

Month Year

repeat

How would I go about this with PHP?

Matt