Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS WordPress Featured Image

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #35370
    tobeeornot
    Member

    I am trying to apply Featured Image to my WP theme and running into some problems.

    First, I am applying the following code to the functions page:


    if ( function_exists( 'add_theme_support' ) ) {
    add_theme_support( 'post-thumbnails' );
    set_post_thumbnail_size( 300, 200, true );
    add_image_size( 'bigger_image', 300, 9999 );
    }

    Second, on the relevant template, I include the relevant code as part of the existing loop:













    'Pages: ', 'next_or_number' => 'number'));?>




    I am thinking this code should also apply the class I have set to ensure the image comes with the styles I want (padding, floated right, etc).

    This is the relevant css:


    img.right{ display:block; float:right;padding:1em 0 1em 1em; background: #063 ;}

    To apply the featured image I upload an image from the page back-end and select featured image. The image is applied but all the styles disappear. Be good to understand why.

    #91444
    TheDoc
    Member

    First of all, this part is wrong:


    You’re calling the image twice and I’ll show you a little tidbit that you can add the class of ‘right’ directly to the image!

     'right')); ?>

    The reason why your class wasn’t working before is because you had ‘img.right’. This will target images with a class of ‘right’ but you had your class on the div wrapping the image, not on the image itself.

    By using the code I’ve provided and getting rid of the div altogether, you won’t need to change the CSS!

    #91449
    tobeeornot
    Member

    @TheDoc – I thought this would be right up your alley. Thanks for explaining the importance how to apply classes to this function and why. It is really helpful.

    I am really pleased with the Featured Image functionality. After I read your blog, I thought that this sort of customization would be great – and it is!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘CSS’ is closed to new topics and replies.