i am just trying to figure out how to create a list of links in my sidebar that show posts that have been given a certain tag.
in so doing, i could just create a new post, give it a tag, and then it would show up in my sidebar as a new link.
for example, if i have tagged 3 posts with “cats” – i would like to have a list in my sidebar with a title “Cats” that shows each post name as a link…like so:
tabby (link to post)
calico (link to post)
abyssinian (link to post)
any advice please?!
thanks kindly, tre.
A little code to play with:
<?php $tags = 'cats'; // separate multiple tags with comma $numposts = '5'; // -1 for all
$myquery = new WP_Query("tag=$tags&showposts=$numposts"); ?> <?php if($myquery->have_posts()) : ?> <ul><li><h2><?php echo ucwords(strtolower($tags)); ?></h2> <ul> <?php while($myquery->have_posts()) : $myquery->the_post(); ?> <li><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></li> <?php endwhile; ?> </ul> </li></ul> <?php endif; ?>
Thanks for that code Kaf.
Interesting, there a number of new additions to the query variables (e.g. tag=) and some of those are explained in Ryan’s Taxonomy Intersections and Unions post.
when I use this code, in the article page, it just list the posts of the category that the post of that page is in.
How I can retrieve other categories’ posts?
this is what I am using:
$recent = new WP_Query(“tag=righttab&showposts=10”); while($recent->have_posts()) : $recent->the_post();?>
” target=”_blank”><?php the_title(); ?>
<?php endwhile; ?>
but only it gives me the page category articles not other categories?
Ok, I’m new to the tag business: but here’s my question: If I add certain tags to a post, I’d like to see underneath my post, say the last 5 posts of which the tags match as much as possible, with the best match on top. Is something like that possible and if so, how? Thanks!
- The topic ‘how-to: list of post titles, matching certain tag – in sidebar?’ is closed to new replies.