• Resolved roburdick

    (@roburdick)


    I would like to be able to do this. Maybe it’s a bit too tehnical for me. On my home page I want the thumbnails to display the post title or image caption when hovering over with the mouse.

    I have tried various workarounds which either did not work or implemented wrong. If anyone understands what I need and knows how I can do it, I would be very grateful.

    I am using thematic with a child theme. I am not great with php or javascript. This is my site.

    https://www.robertburdick.com/

    I have seen something like what I want on the autofocus theme by alan cole: https://allancole.com/themes/index.php?wptheme=AutoFocus
    I think he uses the loop differently, and when I try it, it all breaks!

    Thanks

Viewing 1 replies (of 1 total)
  • Thread Starter roburdick

    (@roburdick)

    I found a post that sorted this out for me. Pop this bit of code in your functions.php file (for child themes set up):

    // caption for thumbs
    function monahans_thumbnail_caption($html, $post_id, $post_thumbnail_id, $size, $attr)
    {
    $attachment =& get_post($post_thumbnail_id);

    // post_title => image title
    // post_excerpt => image caption
    // post_content => image description

    if ($attachment->post_excerpt || $attachment->post_content) {
    $html .= ‘<p class=”thumbcaption”>’;
    if ($attachment->post_excerpt) {
    $html .= ‘<span class=”captitle”>’.$attachment->post_excerpt.'</span> ‘;
    }
    $html .= $attachment->post_content.'</p>’;
    }

    return $html;
    }

    add_action(‘post_thumbnail_html’, ‘monahans_thumbnail_caption’, null, 5);

Viewing 1 replies (of 1 total)
  • The topic ‘Creating a hover caption on thumbnails’ is closed to new replies.