• Hi there,

    When rolling over the homepage images, we would like to have the post title render on the dark gray circle as it does when there is no image at all. I’m assuming this can be done with CSS, but unfortunately I haven’t kept up to date on how such things are achieved. I thought it would be faster to simply ask.

    With thanks,
    Misty

Viewing 2 replies - 16 through 17 (of 17 total)
  • Hi, I am trying to get this to work as well. I am not a javascript or css expert although I can get by. I’ve added this:

    $thumb = get_the_post_thumbnail( $post->ID, 'post-thumbnail', array( 'title' => esc_attr( get_the_title() ) ) ) . '<span class="no-thumbnail">' . get_the_title() . '</span>';

    to the content-home.php file

    and it’s showing the titles underneath the circles.

    to me it makes logical sense that the code is doing this:

    if no thumbnails
    put title
    if thumbnail
    put thumbnail
    endif

    i’m not sure but to me it makes more send to edit something in this part of the code as well:

    if ( $first_attachment ) {
    		foreach ( $first_attachment as $attachment ) {
    			$thumb = wp_get_attachment_image( $attachment->ID, 'post-thumbnail', false, array( 'title' => esc_attr( get_the_title() ) ) );
    		}
    	}
    	else {
    		$thumb = '<span class="no-thumbnail">' . get_the_title() . '</span>';
    		$postclass = 'no-thumbnail';
    	}
    }
    ?>
    
    <article id="post-<?php the_ID(); ?>" <?php post_class( $postclass ); ?>>
    	<a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php echo $thumb; ?></a>
    </article><!-- #post-<?php the_ID(); ?> -->

    or maybe I’m just missing something altogether.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

Viewing 2 replies - 16 through 17 (of 17 total)
  • The topic ‘Show post title over images during rollover’ is closed to new replies.