[resolved] Showing all thumbnails of an attached post (4 posts)

  1. Richard Bui
    Posted 2 years ago #

    So I found this code in the support forum here and it does 95% of what I want, but for the life of me, I can't figure out the last 5%. So here's the code I'm using: http://pastebin.com/1vTHaHSB. It works perfectly. Now the only issue is, I want to be able to wrap it in a DIV like <div id="show-all-thumbs"> or something and also wrap each of the $thumblist in a <li> or something.

    Can anyone help? Thanks!

  2. bcworkz
    Posted 2 years ago #

    Before the foreach line, do $thumblist = '<div id="show-all-thumbs"><ul>';

    Change the $thumblist line to $thumblist .= '<li><a href="'.get_attachment_link($imageID).'">'.$the_b_img.'</a></li>';

    Just above the return do $thumblist .= '</ul></div>';

  3. catacaustic
    very awesome
    Posted 2 years ago #

    To do that you'd add the div tag outside of the foreach() look, and the li tag inside the foreach() loop. But, just to be sure that you're keeping things semantic, I'd suggest using an ol or ul tag instead of a div.

    As a very quick example...

    $thumblist = '<ul id="show-all-thumbs">';
    foreach ($images as $image) {
        // Other code in here...
        $thumblist.= "<li>";
        $thumblist .= '<a href="'.get_attachment_link($imageID).'">'.$the_b_img.'</a>';
        $thumblist.= "</li>";
    $thumblist.= '</ul>';
  4. Richard Bui
    Posted 2 years ago #

    Awesome guys! Thanks so much for the help, it worked perfectly!

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.