Treehouse: Grow your CSS skills. Land your dream job.

Terrible problems with WordPress Featured Images in the loop.

  • # March 25, 2012 at 11:24 pm

    Hey guys, I’m having the worst time styling a few posts-from the loop- with featured images.
    I have the featured image floated to the left.
    It’s enabled in my theme’s function.php file.
    As you can see, I’m not specifically calling it with my code that’s below.
    I’m thinking that might be half my problem.

    I’m going for the standard blog layout that you see everywhere.
    Featured image on the left and then the post’s title and entry excerpt below that.
    As seen on the site, for example.

    If I keep with the floated featured images, the post’s title and entry just stay put in the middle of the div. If I try any margin or padding to move them whatsoever, things go all haywire. I’m thinking that it’s because the floated featured image is just kind of “there”. I’m not specifically calling it in the code. I’m just rambling now. Does anyone have any tips for me, on this?

    Here is the code I’m using to pull in the last 5 posts:

    < ?php query_posts('showposts=5'); ('post_type=post&paged='.get_query_var('paged')); ?>

    < ?php if (have_posts()) : ?> < ?php while (have_posts()) : the_post(); ?>

    " rel="bookmark" title="< ?php the_title(); ?>">< ?php the_title(); ?>

    < ?php
    global $more;
    $more = 0;
    < ?php the_content('Read the rest of this entry »'); ?>

    < ?php endwhile; ?>

    < ?php else : ?>

    Not Found

    < ?php _e("Sorry, no posts or pages could be found. Why not search for what you were trying to find?"); ?>

    < ?php get_search_form(); ?>

    < ?php endif; ?>

    < ?php wp_reset_query(); ?>

    # March 26, 2012 at 1:04 pm

    This isn’t the best solution, but if you’re keen on not having the text wrap under the image, you can do something like this:

    # March 29, 2012 at 10:58 pm

    Hey man! Sorry, I’ve been crazy busy. Thank you for throwing that fiddle together!

    # March 30, 2012 at 12:03 am

    Unfortunately WordPress just won’t play nice. I wish it was something as easy at that, and it should be! Ugh.

    # March 30, 2012 at 1:12 am

    Do you have a link to your site? I can see where you’re going wrong.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.