Wordpress - changing tag pages to use get_posts?

Discussion in 'WordPress' started by Random Guy, Apr 8, 2009.

  1. #1
    I'd like to make my tag pages like a little sitemap, pumping out a big list of links to all the posts in them. Is there a way to find out what tag is currently being shown and send it over to the get_posts command?

    Without a plugin preferably - I don't trust those things :)
     
    Random Guy, Apr 8, 2009 IP
  2. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This might work. I haven't tested it though.
    
    <?php 
    $current_tag = single_tag_title(' ', false);
    $getposts = get_posts('tag='.$current_tag);
    foreach($getposts as $post) : ?>
    <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a>
    <?php endforeach; ?>
    
    Code (markup):
     
    Cash Nebula, Apr 11, 2009 IP
    Random Guy likes this.
  3. just-4-teens

    just-4-teens Peon

    Messages:
    3,967
    Likes Received:
    168
    Best Answers:
    0
    Trophy Points:
    0
    #3
    there is a limit on the maximum number of tags that can be displayed in the tag cloud.

    http://codex.wordpress.org/Template_Tags/wp_tag_cloud#Examples

    what was posted above may work but by default wordpress will display no more than 45 tags
     
    just-4-teens, Apr 12, 2009 IP
  4. fish

    fish Well-Known Member

    Messages:
    450
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #4
    Check out this tutorial on making your search results unlimited: http://wphacks.com/how-to-make-wordpress-search-results-unlimited/

    Yes, I know it's for search, although you can apply the same technique to tag pages as well. Instead of using search.php, put the code in tag.php.

    @just-4-teens: I think he's talking about tag archive pages, not tag clouds.
     
    fish, Apr 12, 2009 IP
  5. just-4-teens

    just-4-teens Peon

    Messages:
    3,967
    Likes Received:
    168
    Best Answers:
    0
    Trophy Points:
    0
    #5
    eso to make an archive you still need to call the tag cloud
     
    just-4-teens, Apr 13, 2009 IP
  6. Random Guy

    Random Guy Peon

    Messages:
    670
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Got it working, thanks folks. Just a quick update for anyone else who might run into this:

    Get_posts doesn't seem to support tags at all (at least in the versions I tried). It'll give you every single blogpost, up to the max # if you try using it. Aka the codex help page is a bit wonky. However, you can fiddle with sticking tags into a WP_Query and then it works :)
     
    Random Guy, Apr 15, 2009 IP