WordPress.org

Ready to get started?Download WordPress

Forums

Spun
Add circle to single page (7 posts)

  1. rkaufman13
    Member
    Posted 1 year ago #

    Hello--loving Spun so far and really appreciate it being free. My site had gone about 2 years without any sort of upgrade or makeover and now it is looking awesome.

    I had a question about adding circles to the single page view. Basically, every post I make has a featured image but not any attached images. I'd like to display the featured image (the same one that a person would have just clicked on to reach the post) and style it the same as on the homepage. I've spent some time messing around with the content-single.php file and made some progress, but wasn't able to get the image to style correctly. It either displayed as a 180px square or, worse, a 700px-wide monster.

    I suppose I could go into each of my posts, add the featured image into the post and figure out how to style them properly, but I was hoping to automate this on the backend. Of course, the more time I spend messing around trying to make it work is time I could have been manually doing this... :)

    My site is in my profile but here's the URL: http://www.readwriterachel.com/

  2. Andrew
    Forum Moderator
    Posted 1 year ago #

    May you link a webpage with the featured image you want styled?

  3. rkaufman13
    Member
    Posted 1 year ago #

    Hi Andrew,
    If I'm understanding you right...

    Click any of the links on the front page, they each go to a single post. I want the featured image from that post to display on the post. So for example the leftmost image in the second row (the lego guys): I want that exact same image, styled the same way, to display when you click on the lego guys.

    Does that make sense?

  4. Andrew
    Forum Moderator
    Posted 1 year ago #

    For example, I can't see your featured image on this page.

  5. rkaufman13
    Member
    Posted 1 year ago #

    That's exactly correct and is not desired behavior. How do I get the featured images to display on that page and all the others?

  6. rkaufman13
    Member
    Posted 1 year ago #

    Maybe the confusion is mine because I deleted the errant code from content-single.php after I realized I was not getting it to work today (without help!). But I was basically using the same code from content-home.php as follows:

    global $post;
    $postclass = '';
    
    if ( '' != get_the_post_thumbnail() ) {
    	$thumb = get_the_post_thumbnail( $post->ID, 'post-thumbnail', array( 'title' => esc_attr( get_the_title() ) ) );
    }
    else {
    	$args = array(
    				'post_type' => 'attachment',
    				'numberposts' => 1,
    				'post_status' => null,
    				'post_mime_type' => 'image',
    				'post_parent' => $post->ID,
    			);
    
    	$first_attachment = get_children( $args );
    
    	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';
    	}
    }

    As far as I can tell, that attaches all the same CSS classes as on the homepage to the resulting HTML code. Yet the expected properties (size, opacity, etc) aren't being applied. If it would help to see it in action I can re-add this not-fully-functional code to the site.

  7. flashbuddy
    Member
    Posted 1 year ago #

    How about using timthumb to auto scale the featured image, then reference the css that creates the circle knockout. Whenever I want to muck around with featured images on the page/post, I generally use timthumb to scale the featured image to the exact size I need on the fly, then style like crazy.

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic