WordPress.org

Forums

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

  1. Richard Bui
    Member
    Posted 1 year 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
    Member
    Posted 1 year 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 1 year 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
    Member
    Posted 1 year 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

Tags

No tags yet.