WordPress.org

Ready to get started?Download WordPress

Forums

Spun
titles with thumbnails (7 posts)

  1. tracyselena2
    Member
    Posted 1 year ago #

    I am using the Spun theme ..and trying to get the title to hover over the thumbnail even if there is a thumbnail. Currently it only shows when there is no image or thumb.

    I am not a javascript or css expert although I can get by. I've added this as per a different post I found in the forums:

    $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.

    in the other thread there was talk of doing what i've done and then just changing the css code..but to me the css code is already done..since it's being used when there is NO thumbnail....so i would think logically it's just the if/then statement that needs to include the title OR not exclude it when there is a thumb.

    i hope this all makes sense

    site: http://greenboutique.ca

  2. Caroline Moore
    Member
    Theme Author

    Posted 1 year ago #

    in the other thread there was talk of doing what i've done and then just changing the css code..but to me the css code is already done

    Not quite. If you examine the CSS, styles for the titles are only applied when the class of post is 'no-thumbnail', which only occurs when there is no thumbnail. So look for .no-thumbnail in the stylesheet to see what styles are applied to the post title when there is no thumbnail, and apply those styles to the printed post titles in your child theme.

    It gets more complicated, because you're also printing the title underneath an IMG block, whereas the no thumbnail title doesn't have to work around an image block at all. You need to use CSS to reposition the title over the image.

    So at this point, it's all about CSS to make it look how you want.

  3. tracyselena2
    Member
    Posted 1 year ago #

    Ok great thank you. :)

  4. deb76
    Member
    Posted 1 year ago #

    @tracyselena2

    Hi tracyselena2!
    I have the same problem on my website. I could see that you found a solution on yours.
    Can you describe me exactly the code using in stylesheet and content-home.php? please?
    I don't find the duplication about the .no-thumbnail and moreover, I'm not really an expert in CSS.

    my url : http://www.lecrindechocolat.com/

    I'm really desperated!!!
    Déb

    PS: I apologize about my english! you're lucky, I 'm not telling in front of you, communication would be impossible! lol

  5. deb76
    Member
    Posted 1 year ago #

    mistake : desperated doesn't exist !!! really desperate !!!!

  6. deb76
    Member
    Posted 1 year ago #

    I revolve my problem thanks to Andrew. After reading more and more topics, I find this link and the perfect solution !
    Thank you so much Andrew!!!

    http://wordpress.org/support/topic/put-test-inside-images-on-home-page?replies=1

  7. Andrew
    Forum Moderator
    Posted 1 year ago #

    You're welcome :)

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic

Tags