WordPress.org

Ready to get started?Download WordPress

Forums

Linked Caption in Thickbox Doubling Up (4 posts)

  1. Brendan@Brilliant
    Member
    Posted 1 year ago #

    If you like puzzles, I've got a good one for you here. I'm building a website for an artist(disclaimer: his design, not mine) and have the native thickbox functionality working properly on the various archive pages of his site. I'm trying to populate the TB caption area with the post content, which works, but it doubles up the link and leaves a hanging closing tag for some reason. Here's the link:
    http://035b058.netsolhost.com/blog/avisualhistorytype/vintage-prints/

    Click on the second thumbnail(For Sale: A Baseball Game) to see what I mean.

    This is how I'm populating the ul:

    <?php
                        if ( has_post_thumbnail()) {
                        $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large');
                        echo '<a class="thickbox" href="' . $large_image_url[0] . '" title="' . get_the_excerpt('echo=0') . '" >';
                        the_post_thumbnail('thumbnail');
                        }
                        ?>
    
        				<span><?php the_title(); ?></span></a></li>

    If anyone has any insight it would be greatly appreciated. I'm hoping that I don't have to scrap this and use a plugin, but I'm starting to think so, because having links in the captions is necessary.

  2. Andrew
    Forum Moderator
    Posted 1 year ago #

    The issue is occurring from your anchor tag's title attribute;

    <a class="thickbox" href="http://035b058.netsolhost.com/blog/wp-content/uploads/2013/02/ABaseBallGameFacebook.jpg" 
    
    title="<a href='http://www.dickperezimmortals.com/abaseballgamefacebook.aspx'>Click here to purchase</a>" >
  3. Brendan@Brilliant
    Member
    Posted 1 year ago #

    I don't know if it's the best way of doing it, but that is intentional. Thickbox grabs the caption from the title attribute, which is inconvenient if you're not coding static links. If you look at the code snippet above, you can see that's coming from this portion:

    echo '<a class="thickbox" href="' . $large_image_url[0] . '" title="' . get_the_excerpt('echo=0') . '" >';

    I needed to do this to populate the caption area dynamically from the excerpt because 1.) I didn't know of another way to enable captions, and 2.) The captions must support HTML characters.

    I hope I didn't misunderstand you, thanks for your feedback.

  4. Andrew
    Forum Moderator
    Posted 1 year ago #

    What does thickbox need from the title attribute? Does it just need a URL, rather than an anchor tag?

Topic Closed

This topic has been closed to new replies.

About this Topic