Support » Plugins » Hacks » Showing all thumbnails of an attached post

  • Resolved Richard Bui


    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: 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!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz


    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>';

    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>';

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Showing all thumbnails of an attached post’ is closed to new replies.