No replies
stoiko's picture
Last seen: 8 years 7 weeks ago
Timezone: GMT+2
Joined: 2013-02-19
Posts: 1
Points: 2

I want a text caption over the image when you hover with the mouse, but I am not sure how to do it in wordpress. I have this code:

<?php while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink(); ?>"> <?php echo inkthemes_main_image(); ?> </a></a>
<?php endwhile; ?>

inkthemes main image is a function that calls the posts's main image:
function inkthemes_main_image() {
    global $post, $posts;
    //This is required to set to Null
    $id = '';
    $the_title = '';
    // Till Here
    $permalink = get_permalink($id);
    $homeLink = get_template_directory_uri();
    $first_img = '';
    $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
    if (isset($matches [1] [0])) {
        $first_img = $matches [1] [0];
    if (empty($first_img)) { //Defines a default image
    } else {
        print "<a href='$permalink'><img src='$first_img' width='140px' height='208px' class='postimg wp-post-image' alt='$the_title' /></a>";

And let's say I want to use one of these captions:
How? I tried putting the style.css in the theme's style, but still didn't work...