WordPress.org

Forums

custom tag page (5 posts)

  1. aminabbasian
    Member
    Posted 4 years ago #

    Hey Guys,

    I am tryng to use a combination of loop.php and tag.php to list the post thumnbails for each tag.

    The code in loop.php is http://pastebin.com/MgdJVGAE

    This lists the posts by title but not the thumbnails.

    I have tried this code http://pastebin.com/2yfE40WK

    but it doesn't quite work.

    Any ideas how I can resolve this?

  2. aminabbasian
    Member
    Posted 4 years ago #

    Please see the codes now in pastebin

  3. aminabbasian
    Member
    Posted 4 years ago #

    OK just an update on this.

    I have started editing tag.php as follows:

    $thumbnails = get_posts('numberposts=0&tag=Summer');
      foreach ($thumbnails as $thumbnail) {
        if ( has_post_thumbnail($thumbnail->ID)) {
          echo '<a href="' . get_permalink( $thumbnail->ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '">';
          echo get_the_post_thumbnail($thumbnail->ID, 'gallery-220');
          echo '</a>';

    This code pulls all the tags under "Summer" but I want to be able to have this as an array of some sort. So that the page pulls the posts according to what the tags is.

    get_posts('numberposts=0&tag=$get_the_tags'); or get_posts('numberposts=0&tag=$tag'); doesn't work.

    I know I can echo the tag as set out here http://codex.wordpress.org/Function_Reference/get_the_tags but how do i uses this to be included within the codes above?

  4. aminabbasian
    Member
    Posted 4 years ago #

    ok figured it out!! :)

    this is the final code

    $posttags = get_the_tags();
    if ($posttags) {
      foreach($posttags as $tag) {
    
      $thumbnails = query_posts("numberposts=0&tag=$tag->name");
      foreach ($thumbnails as $thumbnail) {
        if ( has_post_thumbnail($thumbnail->ID)) {
          echo '<a href="' . get_permalink( $thumbnail->ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '">';
          echo get_the_post_thumbnail($thumbnail->ID, 'gallery-220');
          echo '</a>';
    
        }
      }
        }
    }
  5. aminabbasian
    Member
    Posted 4 years ago #

    just an update on the code above.

    how can i alter the code so that it pulls the tag ID or tag slug?

    At the moment the tag name is pulled but if the tag name consists of two words the page search is blank.

    any suggstions?

Topic Closed

This topic has been closed to new replies.

About this Topic